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

Check bf16 model in torch engine #1270

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

grimoire
Copy link
Collaborator

check bf16 support on v100.

model_config = ModelConfig.from_hf_config(config,
model_path=model_path)
if model_config.dtype == torch.bfloat16:
assert not torch.cuda.is_bf16_supported(), (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种情况下,告警,并 fallback到 fp16,如何?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning 用户不一定会注意,这样更醒目,也能强调 fallback 会造成精度问题。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有可以在 engine 中 fallback 到 fp16的办法呢?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hf_model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch_dtype,

model = AutoModelForCausalLM.from_config(
config,
torch_dtype=torch_dtype,

可以,但是没有办法保证这样的计算结果的正确性。用户也很容易无视 warning。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也好,我们先看看社区的反馈。

@lvhan028 lvhan028 requested a review from RunningLeon March 13, 2024 06:15
Copy link
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lvhan028 lvhan028 changed the title Torch check bf16 model Check bf16 model in torch engine Mar 13, 2024
@lvhan028 lvhan028 merged commit 920d719 into InternLM:main Mar 13, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants