mosaicml / llm-foundry

LLM training code for Databricks foundation models

Home Page:https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to run inference/convert_composer_to_hf.py with MPT-1B model on Habana Gaudi 2, file formats do not match

greg-serochi opened this issue · comments

I’m running the mosaic MPT-1B model on Habana Gaudi 2 and I have a question about the inference/convert_composer_to_hf.py command

  1. the output file format of the train.py does not match the input requirements. train.py gives a zipped .pt.gz, but the convert_composer_to_hf.py expects an unzipped .pt file .
  2. How do you run this convert_composer_to_hf.py with all eight output files, since I'm using 8 Gaudi2

Here’s the steps I run:
docker run -it --name mosaic --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host vault.habana.ai/gaudi-docker/1.13.0/ubuntu22.04/habanalabs/pytorch-installer-2.1.0:latest

git clone -b habana_alpha https://github.com/mosaicml/llm-foundry
pip install -e .
pip install git+https://github.com/HabanaAI/DeepSpeed.git@1.13.0

Set the data prep (it runs correctly):

python data_prep/convert_dataset_hf.py --dataset c4 --data_subset en --out_root my-copy-c4 --splits train_small val_small --concat_tokens 2048 --tokenizer EleutherAI/gpt-neox-20b --eos_text '<|endoftext|>'

Ran the training (it runs correctly):

DEEPSPEED_USE_HPU=1 composer -n 8 --world_size 8 /root/llm-foundry/scripts/train/train.py /root/llm-foundry/scripts/train/yamls/pretrain/mpt-1b-gaudi2.yaml
data_local=my-copy-c4
train_loader.dataset.split=train_small
eval_loader.dataset.split=val_small
deepspeed_config.zero_optimization.stage=3
max_duration=100ba
eval_interval=50ba
save_folder=mpt-1b-training-output

Now that the training is done, there are eight output files in .pt.tar format.

root@hls2-srv01-demolab:~/llm-foundry/scripts# cd mpt-1b-training-output/ && ls
ep0-ba100-rank0.pt.tar ep0-ba100-rank2.pt.tar ep0-ba100-rank4.pt.tar ep0-ba100-rank6.pt.tar latest-rank0.pt.tar latest-rank2.pt.tar latest-rank4.pt.tar latest-rank6.pt.tar
ep0-ba100-rank1.pt.tar ep0-ba100-rank3.pt.tar ep0-ba100-rank5.pt.tar ep0-ba100-rank7.pt.tar latest-rank1.pt.tar latest-rank3.pt.tar latest-rank5.pt.tar latest-rank7.pt.tar

The next step is to run the convert command:
python inference/convert_composer_to_hf.py
--composer_path mpt-1b-training-output/ep0-ba100-rank0.pt
--hf_output_path mpt-1b-training-output-hf
--output_precision bf16 \

When I run this convert script, I obviously get an error: FileNotFoundError: Local path mpt-1b-training-output/ep0-ba100-rank0.pt does not exist

I then run the tar -xvf to unzip the .pt.tar into a new directory called ep0-ba100-rank0.pt and -xvf into the existing directory and get the same error:

IsADirectoryError: [Errno 21] Is a directory: ‘/tmp/tmpbsa91id7/local-composer-checkpoint.pt’

Also how do you run this convert_composer_to_hf.py with all eight output files?

composer_collect_env

[2024-01-28 17:52:18,077] [INFO] [real_accelerator.py:175:get_accelerator] Setting ds_accelerator to hpu (auto detect)
Collecting system information...

System Environment Report
Created: 2024-01-28 17:52:20 UTC

PyTorch information

PyTorch version: 2.1.0a0+gitf8b6084
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.27.7
Libc version: glibc-2.35

Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-88-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 160
On-line CPU(s) list: 0-159
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz
CPU family: 6
Model: 106
Thread(s) per core: 2
Core(s) per socket: 40
Socket(s): 2
Stepping: 6
CPU max MHz: 3400.0000
CPU min MHz: 800.0000
BogoMIPS: 4600.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 3.8 MiB (80 instances)
L1i cache: 2.5 MiB (80 instances)
L2 cache: 100 MiB (80 instances)
L3 cache: 120 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-39,80-119
NUMA node1 CPU(s): 40-79,120-159
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] habana-torch-dataloader==1.13.0.463
[pip3] habana-torch-plugin==1.13.0.463
[pip3] numpy==1.23.5
[pip3] pytorch-lightning==2.1.2
[pip3] pytorch-ranger==0.1.1
[pip3] torch==2.1.0a0+gitf8b6084
[pip3] torch-optimizer==0.3.0
[pip3] torch-tb-profiler==0.4.0
[pip3] torchaudio==2.1.0+6ea1133
[pip3] torchdata==0.7.0+c5f2204
[pip3] torchmetrics==1.0.3
[pip3] torchtext==0.16.0a0+4e255c9
[pip3] torchvision==0.16.0+fbb4cc5
[pip3] triton==2.1.0
[conda] Could not collect

Composer information

Composer version: 0.16.4
Composer commit hash: None
Host processor model name: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz
Host processor core count: 80
Number of nodes: 1
Accelerator model name: N/A
Accelerators per node: 0
CUDA Device Count: 0

Hi, Gaudi support is alpha, and uses Deepspeed in FSDP. Most of the LLM Foundry repo is built around using FSDP, in particular that helper script assumes a single checkpoint file, which is different from what Deepspeed produces. Unfortunately we don't have an easy script for converting from a Deepspeed checkpoint into another format.

Hi Daniel, thanks for the response, and to be clear, I am an Intel Gaudi employee. My goal here is to take what was documented in the blog: https://www.databricks.com/blog/llm-training-and-inference-intel-gaudi2-ai-accelerators and provide the specific
instructions to run the MPT-1B model with 8 Gaudi cards.

Note that the mpt-1b-gaudi2.yaml that is on your github page has FSDP commented out for Gaudi usage, it's not being used.

So how is the blog executing the commands? You show how to run 8 Gaudi Inference using Hugging Face, and it seems like you have to run that convert_composer_to_hf.py to get to Optimum Habana..

we can close this. As the support is early, we'll stay focused on the training section only.

closed