InternLM / InternEvo

Apache License 2.0
262 stars 44 forks source link

[Bug] 好像没有把internevo的MoE权重转换成huggingface版本的脚本? #262

Open Cerberous opened 2 months ago

Cerberous commented 2 months ago

Describe the bug

我好像没有找到用internevo训练然后转换成对应的hf的脚本?请问有提供嘛?

Environment

官方代码

Other information

No response

blankde commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

Cerberous commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

大佬还有一个问题咨询一下,现在的MoE都是基于internlm1的版本,很多参数都不能设置,有基于internlm2的版本的MoE版本嘛

Cerberous commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

blankde commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

是的,internlm2-moe之后也会开源。huggingface版本的MoE modeling.py会跟着转换脚本一起提供的。

Cerberous commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

是的,internlm2-moe之后也会开源。huggingface版本的MoE modeling.py会跟着转换脚本一起提供的。

好的,非常期待!!!

blankde commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

转换脚本目前在 https://github.com/InternLM/InternEvo/pull/271 实现了,可以用 python transformers/convert2hf_internlm_moe.py --src=*** --tgt=*** --tokenizer=*** --topk=2 转换ckpt试一下

Cerberous commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

转换脚本目前在 #271 实现了,可以用 python transformers/convert2hf_internlm_moe.py --src=*** --tgt=*** --tokenizer=*** --topk=2 转换ckpt试一下

可以啦,非常感谢

Cerberous commented 1 month ago

@Cerberous 我们大概下周会把转换脚本开源

还有就是internevo也没有huggingface版本的MoE modeling.py,这个也会提供嘛?

转换脚本目前在 #271 实现了,可以用 python transformers/convert2hf_internlm_moe.py --src=*** --tgt=*** --tokenizer=*** --topk=2 转换ckpt试一下

还有一个问题是我发现提供的hf的modeling_internlm.py里面对shared_experts是直接加到y上的

    y = y + self.shared_experts(orig_inputs)

但是在internevo中实际实现的时候有一个coefficient

if self.use_residual:
    # Residual MoE
    output_mlp = self.residual_mlp(hidden_states)
    if isinstance(output_mlp, tuple):
        output_mlp = output_mlp[0]  # Ignore the bias term for now
    coef = self.coefficient(hidden_states)
    coef = torch.nn.functional.softmax(coef, dim=-1)
    output = output * coef[..., 0:1] + output_mlp * coef[..., 1:]

这里多了一个与结果的加权,如果我没理解错的话这里是没实现的?