Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CogView4 (supports different length c and uc) #10649

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
2640bcf
init
zRzRzRzRzRzRzR Jan 14, 2025
eba11fa
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Jan 14, 2025
6163679
encode with glm
zRzRzRzRzRzRzR Jan 14, 2025
6090ea7
draft schedule
zRzRzRzRzRzRzR Jan 15, 2025
c7d1227
feat(scheduler): Add CogView scheduler implementation
OleehyO Jan 16, 2025
e9f6626
Merge remote-tracking branch 'origin/cogview4' into cogview4
OleehyO Jan 16, 2025
549b357
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Jan 16, 2025
004d002
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Jan 16, 2025
f4457fb
feat(embeddings): add CogView 2D rotary positional embedding
OleehyO Jan 17, 2025
5f8d33b
Merge remote-tracking branch 'origin/cogview4' into cogview4
OleehyO Jan 17, 2025
9a93218
1
zRzRzRzRzRzRzR Jan 17, 2025
ca000dd
Update pipeline_cogview4.py
zRzRzRzRzRzRzR Jan 17, 2025
7ab4a3f
fix the timestep init and sigma
zRzRzRzRzRzRzR Jan 18, 2025
56ceaa6
update latent
zRzRzRzRzRzRzR Jan 19, 2025
a7179a2
draft patch(not work)
zRzRzRzRzRzRzR Jan 19, 2025
c9ddf50
Merge branch 'cogview4'
zRzRzRzRzRzRzR Jan 22, 2025
2f30cc1
Merge pull request #2 from zRzRzRzRzRzRzR/main
zRzRzRzRzRzRzR Jan 22, 2025
e6b8907
fix
zRzRzRzRzRzRzR Jan 22, 2025
0ab7260
[WIP][cogview4]: implement initial CogView4 pipeline
OleehyO Jan 23, 2025
f608f82
[WIP][cogview4][refactor]: Split condition/uncondition forward pass i…
OleehyO Jan 23, 2025
b86bfd4
use with -2 hidden state
zRzRzRzRzRzRzR Jan 23, 2025
c4d1e69
remove text_projector
zRzRzRzRzRzRzR Jan 23, 2025
7916140
1
zRzRzRzRzRzRzR Jan 23, 2025
f8945ce
[WIP] Add tensor-reload to align input from transformer block
OleehyO Jan 24, 2025
bf7f322
[WIP] for older glm
zRzRzRzRzRzRzR Jan 24, 2025
dd6568b
use with cogview4 transformers forward twice of u and uc
zRzRzRzRzRzRzR Jan 25, 2025
6f5407e
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Jan 25, 2025
9e5b991
Update convert_cogview4_to_diffusers.py
zRzRzRzRzRzRzR Jan 25, 2025
36b1682
remove this
zRzRzRzRzRzRzR Jan 26, 2025
804f5cc
Merge pull request #3 from zRzRzRzRzRzRzR/main
zRzRzRzRzRzRzR Jan 28, 2025
16c2397
use main example
zRzRzRzRzRzRzR Jan 28, 2025
601696d
change back
zRzRzRzRzRzRzR Jan 28, 2025
84115dc
reset
zRzRzRzRzRzRzR Jan 28, 2025
95a103f
setback
zRzRzRzRzRzRzR Jan 28, 2025
d932f67
back
zRzRzRzRzRzRzR Jan 28, 2025
b04f15d
back 4
zRzRzRzRzRzRzR Jan 28, 2025
5d33f3f
Fix qkv conversion logic for CogView4 to Diffusers format
zRzRzRzRzRzRzR Jan 28, 2025
b889b37
back5
zRzRzRzRzRzRzR Jan 28, 2025
e239c3c
revert to sat to cogview4 version
zRzRzRzRzRzRzR Jan 28, 2025
310da29
update a new convert from megatron
zRzRzRzRzRzRzR Jan 28, 2025
3bd6d30
[WIP][cogview4]: implement CogView4 attention processor
OleehyO Jan 28, 2025
f826aec
[cogview4] implement CogView4 transformer block
OleehyO Jan 28, 2025
8d8ed8b
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Jan 28, 2025
bf1fdc8
with new attn
zRzRzRzRzRzRzR Jan 28, 2025
6a3a07f
[bugfix] fix dimension mismatch in CogView4 attention
OleehyO Jan 28, 2025
de274f3
[cogview4][WIP]: update final normalization in CogView4 transformer
OleehyO Jan 28, 2025
e94999e
Merge remote-tracking branch 'origin/cogview4' into cogview4
OleehyO Jan 28, 2025
e238284
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Feb 1, 2025
a9b1e16
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Feb 5, 2025
46277b2
1
zRzRzRzRzRzRzR Feb 5, 2025
ebbaa5b
put back
zRzRzRzRzRzRzR Feb 5, 2025
f1ccdd2
Update transformer_cogview4.py
zRzRzRzRzRzRzR Feb 5, 2025
030a467
change time_shift
zRzRzRzRzRzRzR Feb 6, 2025
ad40575
Update pipeline_cogview4.py
zRzRzRzRzRzRzR Feb 6, 2025
81d39ee
change timesteps
zRzRzRzRzRzRzR Feb 6, 2025
45f9e88
fix
zRzRzRzRzRzRzR Feb 6, 2025
1dbeaa8
change text_encoder_id
zRzRzRzRzRzRzR Feb 6, 2025
f209600
[cogview4][rope] align RoPE implementation with Megatron
OleehyO Feb 6, 2025
992f5a3
[cogview4][bugfix] apply silu activation to time embeddings in CogView4
OleehyO Feb 6, 2025
03a1c3b
[cogview4][chore] clean up pipeline code
OleehyO Feb 6, 2025
dd34794
Merge remote-tracking branch 'origin/cogview4' into cogview4
OleehyO Feb 6, 2025
3dab073
[cogview4][scheduler] Implement CogView4 scheduler and pipeline
OleehyO Feb 6, 2025
63982d6
now It work
zRzRzRzRzRzRzR Feb 6, 2025
90a5706
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Feb 6, 2025
d4748e0
add timestep
zRzRzRzRzRzRzR Feb 7, 2025
95f851d
batch
zRzRzRzRzRzRzR Feb 7, 2025
cb56282
change convert scipt
zRzRzRzRzRzRzR Feb 7, 2025
fedf325
refactor pt. 1; make style
a-r-r-o-w Feb 10, 2025
90d29c7
Merge branch 'huggingface:main' into cogview4
zRzRzRzRzRzRzR Feb 10, 2025
4c01c9d
refactor pt. 2
a-r-r-o-w Feb 12, 2025
c1b8004
refactor pt. 3
a-r-r-o-w Feb 12, 2025
9d55d0a
add tests
a-r-r-o-w Feb 12, 2025
5e6de42
make fix-copies
a-r-r-o-w Feb 12, 2025
30dd0ad
Merge branch 'main' into cogview4
a-r-r-o-w Feb 12, 2025
2046cf2
update toctree.yml
a-r-r-o-w Feb 12, 2025
39e1198
use flow match scheduler instead of custom
a-r-r-o-w Feb 13, 2025
b566a9f
Merge branch 'main' into cogview4
a-r-r-o-w Feb 13, 2025
b4c9fde
remove scheduling_cogview.py
a-r-r-o-w Feb 13, 2025
a137e17
add tiktoken to test dependencies
a-r-r-o-w Feb 13, 2025
da420fb
Update src/diffusers/models/embeddings.py
a-r-r-o-w Feb 13, 2025
4003b9c
apply suggestions from review
a-r-r-o-w Feb 13, 2025
35c0ec6
use diffusers apply_rotary_emb
a-r-r-o-w Feb 13, 2025
d328c5e
update flow match scheduler to accept timesteps
a-r-r-o-w Feb 14, 2025
d637d3a
Merge branch 'main' into cogview4
a-r-r-o-w Feb 14, 2025
4c37ef0
fix comment
a-r-r-o-w Feb 14, 2025
90c240b
apply review sugestions
a-r-r-o-w Feb 14, 2025
5c11298
Merge branch 'main' into cogview4
a-r-r-o-w Feb 14, 2025
2f12b7a
Update src/diffusers/schedulers/scheduling_flow_match_euler_discrete.py
a-r-r-o-w Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
264 changes: 264 additions & 0 deletions check_same_sat_megatron_diffusers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
import torch
zRzRzRzRzRzRzR marked this conversation as resolved.
Show resolved Hide resolved
from collections import OrderedDict
from diffusers import CogView4Transformer2DModel

def load_state_dict_sat(file_path):
"""Load the SAT state dictionary from a given file path."""
# Typically, the stored SAT ckpt is in the format: {'module': {...}}
ckpt = torch.load(file_path, map_location="cuda")
return ckpt["module"]


def extract_qkv_from_sat(state_dict, layer_idx):
"""
Extract QKV weights and biases from a SAT state_dict.
Expects keys like:
model.diffusion_model.transformer.layers.{layer_idx}.attention.query_key_value
"""
prefix = f"model.diffusion_model.transformer.layers.{layer_idx}.attention.query_key_value"
w = state_dict[f"{prefix}.weight"].clone()
b = state_dict[f"{prefix}.bias"].clone()
return (w, b)


def load_state_dict_cogview(cogview_path):
"""
Loads the CogView4 model from diffusers and returns its state_dict().
NOTE: You should adjust 'torch_dtype' and 'device_map' as appropriate.
"""
cogview_model = CogView4Transformer2DModel.from_pretrained(
cogview_path, torch_dtype=torch.bfloat16, device_map="auto"
)
return cogview_model.state_dict()


def extract_qkv_from_cogview(state_dict, layer_idx, num_heads, head_dim, hidden_dim):
"""
Extract Q, K, V from CogView4 checkpoint and reshape them into the same shape as SAT’s QKV.
For each layer i:
Q prefix: transformer_blocks.{layer_idx}.attn1.to_q
K prefix: transformer_blocks.{layer_idx}.attn1.to_k
V prefix: transformer_blocks.{layer_idx}.attn1.to_v
Final shape must match SAT's [3*hidden_dim, hidden_dim] for weight, and [3*hidden_dim] for bias.
"""
q_prefix = f"transformer_blocks.{layer_idx}.attn1.to_q"
k_prefix = f"transformer_blocks.{layer_idx}.attn1.to_k"
v_prefix = f"transformer_blocks.{layer_idx}.attn1.to_v"

# Extract
q_weight = state_dict[f"{q_prefix}.weight"].clone()
k_weight = state_dict[f"{k_prefix}.weight"].clone()
v_weight = state_dict[f"{v_prefix}.weight"].clone()

q_bias = state_dict[f"{q_prefix}.bias"].clone()
k_bias = state_dict[f"{k_prefix}.bias"].clone()
v_bias = state_dict[f"{v_prefix}.bias"].clone()

# Reshape weights: [hidden_dim, hidden_dim] -> [num_heads, head_dim, hidden_dim]
# Then concat along the first dimension (which will become 3*num_heads*head_dim)
q_weight = q_weight.view(num_heads, head_dim, hidden_dim)
k_weight = k_weight.view(num_heads, head_dim, hidden_dim)
v_weight = v_weight.view(num_heads, head_dim, hidden_dim)

qkv_weight = torch.cat([q_weight, k_weight, v_weight], dim=0) # shape: (3*num_heads, head_dim, hidden_dim)
qkv_weight = qkv_weight.view(3 * num_heads * head_dim, hidden_dim) # flatten

# Reshape biases: [hidden_dim] -> [num_heads, head_dim]
q_bias = q_bias.view(num_heads, head_dim)
k_bias = k_bias.view(num_heads, head_dim)
v_bias = v_bias.view(num_heads, head_dim)

qkv_bias = torch.cat([q_bias, k_bias, v_bias], dim=0) # (3*num_heads, head_dim)
qkv_bias = qkv_bias.view(3 * num_heads * head_dim)

return (qkv_weight, qkv_bias)

def create_sat_state_dict_from_megatron(megatron_ckpt_dict, num_layers=48, num_heads=32, hidden_size=3072):
"""
Convert a loaded Megatron checkpoint's 'model' dictionary into the same
format used by SAT. This returns something like {'module': {...}} for
easy comparison with SAT.

The code below is adapted from your 'create_sat_state_dict' function,
but we rename it here to keep it direct.
"""
from tqdm import tqdm

hidden_size_per_head = hidden_size // num_heads
mega_weight = megatron_ckpt_dict["model"]
sat_weight = {}

# --- patch_embed ---
sat_weight["model.diffusion_model.mixins.patch_embed.proj.weight"] = \
mega_weight["encoder_expand_linear.weight"].reshape(hidden_size, 64).clone()
sat_weight["model.diffusion_model.mixins.patch_embed.proj.bias"] = \
mega_weight["encoder_expand_linear.bias"].clone()

sat_weight["model.diffusion_model.mixins.patch_embed.text_proj.weight"] = \
mega_weight["text_projector.weight"].clone()
sat_weight["model.diffusion_model.mixins.patch_embed.text_proj.bias"] = \
mega_weight["text_projector.bias"].clone()

# --- time embedding ---
sat_weight["model.diffusion_model.time_embed.0.weight"] = \
mega_weight["time_embedding.time_embed.0.weight"].clone()
sat_weight["model.diffusion_model.time_embed.0.bias"] = \
mega_weight["time_embedding.time_embed.0.bias"].clone()
sat_weight["model.diffusion_model.time_embed.2.weight"] = \
mega_weight["time_embedding.time_embed.2.weight"].clone()
sat_weight["model.diffusion_model.time_embed.2.bias"] = \
mega_weight["time_embedding.time_embed.2.bias"].clone()

# --- label embedding ---
sat_weight["model.diffusion_model.label_emb.0.0.weight"] = \
mega_weight["label_embedding.label_embed.0.weight"].clone()
sat_weight["model.diffusion_model.label_emb.0.0.bias"] = \
mega_weight["label_embedding.label_embed.0.bias"].clone()
sat_weight["model.diffusion_model.label_emb.0.2.weight"] = \
mega_weight["label_embedding.label_embed.2.weight"].clone()
sat_weight["model.diffusion_model.label_emb.0.2.bias"] = \
mega_weight["label_embedding.label_embed.2.bias"].clone()

# --- layers ---
for i in tqdm(range(num_layers), desc="Converting Megatron->SAT"):
# attention output
sat_weight[f"model.diffusion_model.transformer.layers.{i}.attention.dense.weight"] = \
mega_weight[f"decoder.layers.{i}.self_attention.linear_proj.weight"].clone()
sat_weight[f"model.diffusion_model.transformer.layers.{i}.attention.dense.bias"] = \
mega_weight[f"decoder.layers.{i}.self_attention.linear_proj.bias"].clone()

# QKV
qkv_weight = mega_weight[f"decoder.layers.{i}.self_attention.linear_qkv.weight"].clone()
qkv_bias = mega_weight[f"decoder.layers.{i}.self_attention.linear_qkv.bias"].clone()

# Reshape QKV from Megatron format into SAT format
# qkv_weight: [3*hidden_size, hidden_size] -> [num_heads, 3, hidden_size_per_head, hidden_size] -> ...
sat_weight[f"model.diffusion_model.transformer.layers.{i}.attention.query_key_value.weight"] = \
qkv_weight.view(num_heads, 3, hidden_size_per_head, hidden_size) \
.permute(1, 0, 2, 3) \
.reshape(3 * hidden_size, hidden_size).clone()
sat_weight[f"model.diffusion_model.transformer.layers.{i}.attention.query_key_value.bias"] = \
qkv_bias.view(num_heads, 3, hidden_size_per_head) \
.permute(1, 0, 2) \
.reshape(3 * hidden_size) \
.clone()

# MLP
sat_weight[f"model.diffusion_model.transformer.layers.{i}.mlp.dense_h_to_4h.weight"] = \
mega_weight[f"decoder.layers.{i}.mlp.linear_fc1.weight"].clone()
sat_weight[f"model.diffusion_model.transformer.layers.{i}.mlp.dense_h_to_4h.bias"] = \
mega_weight[f"decoder.layers.{i}.mlp.linear_fc1.bias"].clone()

sat_weight[f"model.diffusion_model.transformer.layers.{i}.mlp.dense_4h_to_h.weight"] = \
mega_weight[f"decoder.layers.{i}.mlp.linear_fc2.weight"].clone()
sat_weight[f"model.diffusion_model.transformer.layers.{i}.mlp.dense_4h_to_h.bias"] = \
mega_weight[f"decoder.layers.{i}.mlp.linear_fc2.bias"].clone()

# AdaLN
adaln_weight = mega_weight[f"decoder.layers.{i}.adaln.weight"].clone()
adaln_bias = mega_weight[f"decoder.layers.{i}.adaln.bias"].clone()

sat_weight[f"model.diffusion_model.mixins.adaln.adaln_modules.{i}.1.weight"] = adaln_weight.clone()
sat_weight[f"model.diffusion_model.mixins.adaln.adaln_modules.{i}.1.bias"] = adaln_bias.clone()

# --- final layers ---
sat_weight["model.diffusion_model.mixins.final_layer.adaln.1.weight"] = \
mega_weight["adaln_final.weight"].clone()
sat_weight["model.diffusion_model.mixins.final_layer.adaln.1.bias"] = \
mega_weight["adaln_final.bias"].clone()
sat_weight["model.diffusion_model.mixins.final_layer.linear.weight"] = \
mega_weight["output_projector.weight"].clone()
sat_weight["model.diffusion_model.mixins.final_layer.linear.bias"] = \
mega_weight["output_projector.bias"].clone()

return OrderedDict(sat_weight)


def load_state_dict_megatron_and_convert_to_sat(megatron_ckpt_path, num_layers, num_heads, hidden_size):
"""
Load a Megatron checkpoint from <megatron_ckpt_path>, then convert it into
an SAT-style OrderedDict for direct QKV comparison.

Typically, <megatron_ckpt_path> = ".../iter_0287500/mp_rank_00/model_optim_rng.pt"
"""
ckpt = torch.load(megatron_ckpt_path, map_location="cuda")
# Convert to SAT
sat_like_weight = create_sat_state_dict_from_megatron(
ckpt, num_layers=num_layers, num_heads=num_heads, hidden_size=hidden_size
)
return sat_like_weight

def compute_l2_difference(tensor1, tensor2):
"""Compute L2 norm of the difference between two tensors."""
return torch.norm(tensor1 - tensor2, p=2).item()


def compare_qkv(qkv1, qkv2, name1="Model1", name2="Model2", atol=1e-6):
"""
Compare QKV from two different sources (each is a tuple of (weight, bias)).
Returns (weight_match, bias_match, weight_l2, bias_l2).
"""
w1, b1 = qkv1
w2, b2 = qkv2

weight_match = torch.allclose(w1, w2, atol=atol)
bias_match = torch.allclose(b1, b2, atol=atol)
weight_l2_diff = compute_l2_difference(w1, w2)
bias_l2_diff = compute_l2_difference(b1, b2)

if not (weight_match and bias_match):
print(f"[QKV Mismatch] {name1} vs {name2}")
print(f" Weight L2: {weight_l2_diff:.6f}, Bias L2: {bias_l2_diff:.6f}")
else:
# If everything matches well:
print(f"[QKV Match] {name1} vs {name2} (Weight L2={weight_l2_diff:.6f}, Bias L2={bias_l2_diff:.6f})")

return weight_match, bias_match, weight_l2_diff, bias_l2_diff

if __name__ == "__main__":
num_layers = 28
num_heads = 32
hidden_dim = 4096
head_dim = hidden_dim // num_heads

sat_ckpt_path = "/share/home/zyx/Models/Megatron-VLM/examples/dit/ckpts/pt_sat/0287500/mp_rank_00_model_states.pt"
sat_state_dict = load_state_dict_sat(sat_ckpt_path)

cogview_path = "/share/zyx/CogView4-6B-0128/transformer" # directory containing model index for diffusers
cogview_state_dict = load_state_dict_cogview(cogview_path)

megatron_ckpt_path = "/share/home/zyx/Models/Megatron-VLM/examples/dit/ckpts/pt_ema/iter_0287500/mp_rank_00/model_optim_rng.pt"
mega_as_sat_state_dict = load_state_dict_megatron_and_convert_to_sat(
megatron_ckpt_path,
num_layers=num_layers,
num_heads=num_heads,
hidden_size=hidden_dim
)

print("\n==== Start QKV Comparison ====\n")
for layer_idx in range(num_layers):
print(f"--- Layer {layer_idx} ---")

# Extract QKV from SAT
sat_qkv = extract_qkv_from_sat(sat_state_dict, layer_idx)

# Extract QKV from CogView
cogview_qkv = extract_qkv_from_cogview(
cogview_state_dict, layer_idx, num_heads, head_dim, hidden_dim
)

# Extract QKV from Megatron->SAT
mega_qkv = extract_qkv_from_sat(mega_as_sat_state_dict, layer_idx)

# Compare: SAT vs CogView
compare_qkv(sat_qkv, cogview_qkv, name1="SAT", name2="CogView4")

# Compare: SAT vs Megatron
compare_qkv(sat_qkv, mega_qkv, name1="SAT", name2="Megatron")

# Compare: CogView vs Megatron (optional)
compare_qkv(cogview_qkv, mega_qkv, name1="CogView4", name2="Megatron")

print()

print("=== Done ===")
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
title: ConsisIDTransformer3DModel
- local: api/models/cogview3plus_transformer2d
title: CogView3PlusTransformer2DModel
- local: api/models/cogview4_transformer2d
title: CogView4Transformer2DModel
- local: api/models/dit_transformer2d
title: DiTTransformer2DModel
- local: api/models/flux_transformer
Expand Down
30 changes: 30 additions & 0 deletions docs/source/en/api/models/cogview4_transformer2d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--Copyright 2024 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License. -->

# CogView4Transformer2DModel

A Diffusion Transformer model for 2D data from [CogView4]()

The model can be loaded with the following code snippet.

```python
from diffusers import CogView3PlusTransformer2DModel
zRzRzRzRzRzRzR marked this conversation as resolved.
Show resolved Hide resolved

transformer = CogView3PlusTransformer2DModel.from_pretrained("THUDM/CogView4-6B", subfolder="transformer", torch_dtype=torch.bfloat16).to("cuda")
zRzRzRzRzRzRzR marked this conversation as resolved.
Show resolved Hide resolved
```

## CogView4Transformer2DModel

[[autodoc]] CogView4Transformer2DModel

## Transformer2DModelOutput

[[autodoc]] models.modeling_outputs.Transformer2DModelOutput
34 changes: 34 additions & 0 deletions docs/source/en/api/pipelines/cogview4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-->

# CogView4

<Tip>

Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-a-pipeline) section to learn how to efficiently load the same components into multiple pipelines.

</Tip>

This pipeline was contributed by [zRzRzRzRzRzRzR](https://github.com/zRzRzRzRzRzRzR). The original codebase can be found [here](https://huggingface.co/THUDM). The original weights can be found under [hf.co/THUDM](https://huggingface.co/THUDM).

## CogView4Pipeline

[[autodoc]] CogView4Pipeline
- all
- __call__

## CogView4PipelineOutput

[[autodoc]] pipelines.cogview4.pipeline_output.CogView4PipelineOutput
Loading