Run this model with HF Jobs

Run microsoft/phi-2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/microsoft/phi-2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/microsoft/phi-2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/microsoft/phi-2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/microsoft/phi-2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Disabled autocast

#109
by miguelcarv - opened

In line 306 and 307 of modeling_phi.py autocast is disabled due to overflow issues when using fp16. Bfloat16 does not have these issues so it should not be disabled in this case, right?

Also, wasn't Phi-2 trained in mixed precision fp16? Why wasn't this an issue when training but it seems to be in inference?

Same question, can we simply enable autocast?

@xueyanz actually I do think that is needed, even if using bfloat16. For some reason autocasting the forward of the attention module leads to instability issues in training. I will keep disabling autocast

Thanks so much for your prompt reply, I am trying to train phi2 in a VLM model using auto-cast. To disable autocast, do you manually transfer to fp16?

I load it in fp32 and use torch.amp with bfloat16. The last version of modeling_phi.py already disables autocast by itself in the forward method of the attention module. I'm actually also building a VLM using phi-2, would you care to explain what you are doing at a high level? Also, MoE-LLaVa states that there are training instabilities when using phi-2, maybe because they used a past version of the modeling_phi.py file.

I am using the inference api on huggingface. I attempted to load and access the model using the huggingface production end points. I gave up after several attempts. Any special settings or configs I need to be aware of to enable on a private huggingface inference api? Would help heaps.

I load it in fp32 and use torch.amp with bfloat16. The last version of modeling_phi.py already disables autocast by itself in the forward method of the attention module. I'm actually also building a VLM using phi-2, would you care to explain what you are doing at a high level? Also, MoE-LLaVa states that there are training instabilities when using phi-2, maybe because they used a past version of the modeling_phi.py file.

I will not train the language model, so I simply enable Autocast to see the performance, and the inference result seems reasonable. I am building vlm along the lines of my work in the past.

ok, it seems that auto-casting would make the outputs NaN even during evaluation.

Edited - nevermind - I figured out how to use float16 & bfloat16 without needing to autocast. Thank you.

Edited - nevermind - I figured out how to use float16 & bfloat16 without needing to autocast. Thank you.

Care to share what you did? Thanks.

Sign up or log in to comment