Skip to content

Commit bf7f322

Browse files
[WIP] for older glm
1 parent f8945ce commit bf7f322

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

scripts/convert_cogview4_to_diffusers.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
python scripts/convert_cogview4_to_diffusers.py \
99
--transformer_checkpoint_path 'your path/cogview4_6b/1/mp_rank_00_model_states.pt' \
1010
--vae_checkpoint_path 'your path/cogview4_6b/imagekl_ch16.pt' \
11-
--output_path "/raid/yiyi/CogBiew4-6B" \
11+
--output_path "THUDM/CogView4-6B" \
1212
--dtype "bf16"
1313
1414
Arguments:
@@ -209,12 +209,21 @@ def main(args):
209209
if dtype is not None:
210210
vae = vae.to(dtype=dtype)
211211

212-
text_encoder_id = "THUDM/glm-4-9b-hf"
213-
tokenizer = PreTrainedTokenizerFast.from_pretrained(text_encoder_id)
214-
text_encoder = GlmForCausalLM.from_pretrained(
212+
# text_encoder_id = "THUDM/glm-4-9b-hf"
213+
# tokenizer = PreTrainedTokenizerFast.from_pretrained(text_encoder_id)
214+
# text_encoder = GlmForCausalLM.from_pretrained(
215+
# text_encoder_id,
216+
# cache_dir=args.text_encoder_cache_dir,
217+
# torch_dtype=torch.bfloat16 if args.dtype == "bf16" else torch.float32,
218+
# )
219+
from transformers import AutoTokenizer,AutoModel
220+
text_encoder_id = "/share/home/zyx/Models/Megatron-VLM/examples/dit/ckpts/glm-4-9b"
221+
tokenizer = AutoTokenizer.from_pretrained(text_encoder_id,trust_remote_code=True)
222+
text_encoder = AutoModel.from_pretrained(
215223
text_encoder_id,
216224
cache_dir=args.text_encoder_cache_dir,
217225
torch_dtype=torch.bfloat16 if args.dtype == "bf16" else torch.float32,
226+
trust_remote_code = True
218227
)
219228
# Apparently, the conversion does not work anymore without this :shrug:
220229
for param in text_encoder.parameters():

src/diffusers/models/normalization.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,9 @@ def __init__(
333333

334334
def forward(self, x: torch.Tensor, conditioning_embedding: torch.Tensor) -> torch.Tensor:
335335
# convert back to the original dtype in case `conditioning_embedding`` is upcasted to float32 (needed for hunyuanDiT)
336-
337-
####################################
338336
emb = self.linear(self.silu(conditioning_embedding).to(x.dtype))
339-
# emb = self.linear(conditioning_embedding).to(x.dtype)
340-
####################################
341-
342337
scale, shift = torch.chunk(emb, 2, dim=1)
343-
344-
############################
345338
x = self.norm(x) * (1 + scale)[:, None, :] + shift[:, None, :]
346-
# x = x * (1 + scale)[:, None, :] + shift[:, None, :]
347-
############################
348339
return x
349340

350341

0 commit comments

Comments
 (0)