Merge remote-tracking branch 'origin/main' into dev/vllm-align
This commit is contained in:
commit
663976b8ca
2 files changed
+29
-43
No files matched your search
@@ -1588,20 +1588,6 @@ class HunyuanFusedMoE(SharedFusedMoE):
|
||||
self._init_hook_handle.remove()
|
||||
|
||||
def forward(self, hidden_states, router_logits):
|
||||
from vllm.model_executor.layers.fused_moe.layer import get_forward_context
|
||||
|
||||
ctx = get_forward_context()
|
||||
if not ctx.remaining_moe_layers:
|
||||
import re
|
||||
|
||||
moe_names = [name for name in ctx.no_compile_layers.keys() if ".mlp.experts" in name]
|
||||
|
||||
def get_layer_num(name):
|
||||
match = re.search(r"layers\.(\d+)\.mlp", name)
|
||||
return int(match.group(1)) if match else -1
|
||||
|
||||
moe_names.sort(key=get_layer_num, reverse=True)
|
||||
ctx.remaining_moe_layers.extend(moe_names)
|
||||
return super().forward(hidden_states, router_logits)
|
||||
|
||||
|
||||
|
||||
@@ -804,17 +804,14 @@ class HunyuanImage3Pipeline(HunyuanImage3PreTrainedModel, GenerationMixin):
|
||||
)
|
||||
kwargs["num_image_tokens"] = num_image_tokens
|
||||
# 50 and 5.0 hard code
|
||||
from vllm.forward_context import set_forward_context
|
||||
|
||||
with set_forward_context(None, self.vllm_config):
|
||||
results = self.pipeline(
|
||||
batch_size=len(batch_gen_image_info),
|
||||
image_size=[batch_gen_image_info[0].image_height, batch_gen_image_info[0].image_width],
|
||||
num_inference_steps=kwargs.get("num_inference_steps", 50),
|
||||
guidance_scale=kwargs.get("guidance_scale", 5.0),
|
||||
generator=generator,
|
||||
model_kwargs=kwargs,
|
||||
)
|
||||
results = self.pipeline(
|
||||
batch_size=len(batch_gen_image_info),
|
||||
image_size=[batch_gen_image_info[0].image_height, batch_gen_image_info[0].image_width],
|
||||
num_inference_steps=kwargs.get("num_inference_steps", 50),
|
||||
guidance_scale=kwargs.get("guidance_scale", 5.0),
|
||||
generator=generator,
|
||||
model_kwargs=kwargs,
|
||||
)
|
||||
samples = results[0]
|
||||
return samples
|
||||
|
||||
@@ -929,24 +926,27 @@ class HunyuanImage3Pipeline(HunyuanImage3PreTrainedModel, GenerationMixin):
|
||||
)
|
||||
|
||||
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
||||
outputs = self.model(
|
||||
input_ids=input_ids,
|
||||
attention_mask=attention_mask,
|
||||
position_ids=position_ids,
|
||||
past_key_values=past_key_values,
|
||||
inputs_embeds=inputs_embeds,
|
||||
use_cache=use_cache,
|
||||
output_attentions=output_attentions,
|
||||
output_hidden_states=output_hidden_states,
|
||||
return_dict=return_dict,
|
||||
custom_pos_emb=custom_pos_emb,
|
||||
mode=mode,
|
||||
first_step=first_step,
|
||||
query_lens=query_lens,
|
||||
seq_lens=seq_lens,
|
||||
num_image_tokens=num_image_tokens,
|
||||
gen_timestep_scatter_index=gen_timestep_scatter_index,
|
||||
)
|
||||
from vllm.forward_context import set_forward_context
|
||||
|
||||
with set_forward_context(None, self.vllm_config):
|
||||
outputs = self.model(
|
||||
input_ids=input_ids,
|
||||
attention_mask=attention_mask,
|
||||
position_ids=position_ids,
|
||||
past_key_values=past_key_values,
|
||||
inputs_embeds=inputs_embeds,
|
||||
use_cache=use_cache,
|
||||
output_attentions=output_attentions,
|
||||
output_hidden_states=output_hidden_states,
|
||||
return_dict=return_dict,
|
||||
custom_pos_emb=custom_pos_emb,
|
||||
mode=mode,
|
||||
first_step=first_step,
|
||||
query_lens=query_lens,
|
||||
seq_lens=seq_lens,
|
||||
num_image_tokens=num_image_tokens,
|
||||
gen_timestep_scatter_index=gen_timestep_scatter_index,
|
||||
)
|
||||
hidden_states = outputs[0]
|
||||
|
||||
if mode == "gen_text":
|
||||
|
||||
Reference in new issue
Block a user