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

[BUG]: Running ColossalAI in H800 with torch 2.0 #5594

Open
wxthu opened this issue Apr 13, 2024 · 28 comments
Open

[BUG]: Running ColossalAI in H800 with torch 2.0 #5594

wxthu opened this issue Apr 13, 2024 · 28 comments
Labels
bug Something isn't working

Comments

@wxthu
Copy link

wxthu commented Apr 13, 2024

🐛 Describe the bug

I am running example codes show in https://github.com/hpcaitech/ColossalAI/tree/main/examples/language/gpt/experiments/auto_parallel with Pytorch 2.0 (because I need to deploy colossal in H800 which needs cuda at least 12.0 matched with pytorch at least 2.0)

However, I meet the following error:
image

Then I replace _checkpoint_without_reentrant_generator with _checkpoint_without_reentrant , re-run colossalai run --nproc_per_node 4 auto_parallel_with_gpt.py , I got the following errors:
image
It seems that the current code is not compatible with the new version of the API (torch 2.0+)

Environment

PyTorch version: 2.0.0
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

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

Python version: 3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-101-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090
GPU 2: NVIDIA GeForce RTX 3090
GPU 3: NVIDIA GeForce RTX 3090
GPU 4: NVIDIA GeForce RTX 3090
GPU 5: NVIDIA GeForce RTX 3090
GPU 6: NVIDIA GeForce RTX 3090
GPU 7: NVIDIA GeForce RTX 3090

Nvidia driver version: 535.161.08
cuDNN version: Could not collect
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, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             80
On-line CPU(s) list:                0-79
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 20
Socket(s):                          2
Stepping:                           7
CPU max MHz:                        4000.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4200.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 cdp_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 mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          1.3 MiB (40 instances)
L1i cache:                          1.3 MiB (40 instances)
L2 cache:                           40 MiB (40 instances)
L3 cache:                           55 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78
NUMA node1 CPU(s):                  1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
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:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.0.0
[pip3] torchaudio==2.0.0
[pip3] torchvision==0.15.0
[pip3] triton==2.0.0
[conda] blas                      1.0                         mkl
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344
[conda] mkl-service               2.4.0           py310h5eee18b_1
[conda] mkl_fft                   1.3.8           py310h5eee18b_0
[conda] mkl_random                1.2.4           py310hdb19cb5_0
[conda] numpy                     1.26.4          py310h5f9d8c6_0
[conda] numpy-base                1.26.4          py310hb5e798b_0
[conda] pytorch                   2.0.0           py3.10_cuda11.7_cudnn8.5.0_0    pytorch
[conda] pytorch-cuda              11.7                 h778d358_5    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch                     2.2.2                    pypi_0    pypi
[conda] torchaudio                2.0.0               py310_cu117    pytorch
[conda] torchtriton               2.0.0                     py310    pytorch
[conda] torchvision               0.17.2                   pypi_0    pypi
[conda] triton                    2.2.0                    pypi_0    pypi
@wxthu wxthu added the bug Something isn't working label Apr 13, 2024
@wxthu
Copy link
Author

wxthu commented Apr 14, 2024

@Edenzzzz

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@Edenzzzz

@Edenzzzz
Copy link
Contributor

Hi,
Yes, I believe based on the readme you need torch 1.12 to run it. In fact some of these legacy APIs are under migration and are not guaranteed to be runnable, but I'll try some fixes tomorrow.

@wxthu
Copy link
Author

wxthu commented Apr 14, 2024

Hi, Yes, I believe based on the readme you need torch 1.12 to run it. In fact some of these legacy APIs are under migration and are not guaranteed to be runnable, but I'll try some fixes tomorrow.

I know. But I want to deploy colossal on NVIDIA H800 GPU which only support cuda 12. Based on cuda 12, I can only install pytorch 2.0+ not 1.12.... Could you give me some further suggestions?

@Edenzzzz
Copy link
Contributor

Sorry, I think the current auto parallel is less performant and popular so we didn't adapt it to the newest version. Do you have a compelling reason to use it?
Otherwise, it's advised to use the HybridParallelPlugin or Gemini (ZeRO 3 with chunk-based memory management)

@wxthu
Copy link
Author

wxthu commented Apr 17, 2024

I don't necessarily have to use Auto Parallel Strategy . What I mean is that the official demos provided now are all based on the Torch 1.12 API, but on H800, only Torch 2.0+ can be used, which means I can't deploy training plans on H800.

@Edenzzzz
Copy link
Contributor

Other demos should work on torch 2.0

@wxthu
Copy link
Author

wxthu commented Apr 17, 2024

Could you give me some examples ? I have tried many training demo codes but they all failed on torch 2.0 but succeeded on torch 1.12..

@Edenzzzz
Copy link
Contributor

Could you try examples/language/gpt/gemini and examples/language/gpt/hybridparallelism?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Could you try examples/language/gpt/gemini and examples/language/gpt/hybrid parallelism?

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

Could you try examples/language/gpt/gemini and examples/language/gpt/hybridparallelism?

image It seems that transformer api is not compatible with current colossal ai

@Edenzzzz
Copy link
Contributor

I have fixed this so pulling from the newest main branch should work

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

image api-version matching problem too

@Edenzzzz
Copy link
Contributor

Could you either install apex from source or set enable_all_optimization=False? Thanks.

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

I have re-compiled and re-installed apex from source and run the programs , got the following:

/usr/local/lib/python3.10/dist-packages/colossalai/nn/optimizer/hybrid_adam.py:90: UserWarning: The torch.cuda.*DtypeTensor constructors are no longer recommended. It's best to use methods such as torch.tensor(data, dtype=*, device='cuda') to create tensors. (Triggered internally at ../torch/csrc/tensor/python_tensor.cpp:83.)
  self._dummy_overflow_buf = torch.cuda.IntTensor([0])
Some weights of GPT2ForSequenceClassification were not initialized from the model checkpoint at gpt2 and are newly initialized: ['score.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Epoch [1/3]:   0%|                                                                                                                     | 0/57 [00:00<?, ?it/s]Some weights of GPT2ForSequenceClassification were not initialized from the model checkpoint at gpt2 and are newly initialized: ['score.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Epoch [1/3]:   0%|                                                                                                                     | 0/57 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/root/ColossalAI/examples/language/gpt/hybridparallelism/finetune.py", line 313, in <module>
    main()
  File "/root/ColossalAI/examples/language/gpt/hybridparallelism/finetune.py", line 293, in main
    train_epoch(epoch, model, optimizer, _criterion, lr_scheduler, train_dataloader, booster, coordinator)
  File "/root/ColossalAI/examples/language/gpt/hybridparallelism/finetune.py", line 147, in train_epoch
    outputs = booster.execute_pipeline(
  File "/usr/local/lib/python3.10/dist-packages/colossalai/booster/booster.py", line 205, in execute_pipeline
    return self.plugin.execute_pipeline(data_iter, model, criterion, optimizer, return_loss, return_outputs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/booster/plugin/hybrid_parallel_plugin.py", line 1259, in execute_pipeline
    outputs = self.schedule.forward_backward_step(
  File "/usr/local/lib/python3.10/dist-packages/colossalai/pipeline/schedule/one_f_one_b.py", line 445, in forward_backward_step
    result = self.run_forward_backward(model, data_iter, criterion, optimizer, return_loss, return_outputs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/pipeline/schedule/one_f_one_b.py", line 365, in run_forward_backward
    output_obj = self.forward_step(model, input_obj, criterion, accum_loss, outputs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/pipeline/schedule/one_f_one_b.py", line 249, in forward_step
    output_obj = model_forward(model, micro_batch, input_obj)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/pipeline/schedule/_utils.py", line 120, in model_forward
    return model(**data, **internal_inputs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/booster/plugin/hybrid_parallel_plugin.py", line 197, in forward
    return super().forward(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/interface/model.py", line 25, in forward
    return self.module(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/shardformer/modeling/gpt2.py", line 718, in gpt2_for_sequence_classification_forward
    outputs = GPT2PipelineForwards.gpt2_model_forward(
  File "/usr/local/lib/python3.10/dist-packages/colossalai/shardformer/modeling/gpt2.py", line 260, in gpt2_model_forward
    outputs = block(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/transformers/models/gpt2/modeling_gpt2.py", line 390, in forward
    attn_outputs = self.attn(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/shardformer/modeling/gpt2.py", line 840, in forward
    attn_output = ColoAttention.attention(query, key, value, **attention_mask, dropout_p=dropout_p, scale=scale)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/shardformer/layer/attn.py", line 250, in attention
    attn_func = ColoAttention._dispatch_kernel(q.dtype, mask_type)
  File "/usr/local/lib/python3.10/dist-packages/colossalai/shardformer/layer/attn.py", line 98, in _dispatch_kernel
    ].load()
  File "/usr/local/lib/python3.10/dist-packages/colossalai/kernel/kernel_loader.py", line 73, in load
    assert len(usable_exts) != 0, f"No usable kernel found for {self.__class__.__name__} on the current machine."
AssertionError: No usable kernel found for FlashAttentionWithPaddingMaskLoader on the current machine.
Some weights of GPT2ForSequenceClassification were not initialized from the model checkpoint at gpt2 and are newly initialized: ['score.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

@Edenzzzz
Copy link
Contributor

Edenzzzz commented Apr 19, 2024

You'll need to either set enable_all_optimization=False or pip install flash-attn

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

pip install flash-attn

set enable_all_optimization for colossal or apex?

@Edenzzzz
Copy link
Contributor

image

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

fix and thanks

@wxthu wxthu closed this as completed Apr 19, 2024
@wxthu wxthu reopened this Apr 19, 2024
@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

I have solved all the issues related to system env and when I re-run the program in ~/ColossalAI/examples/language/gpt/hybridparallelism I got the ProcessError:
image

@wxthu
Copy link
Author

wxthu commented Apr 19, 2024

image but this file really exists

@wxthu wxthu closed this as completed Apr 20, 2024
@wxthu
Copy link
Author

wxthu commented May 6, 2024

when I run the examples in ColossalAI/examples/language/gpt/hybridparallelism/ using command colossalai run --nproc_per_node=2 finetune.py, I always got the following error:
image
On the other hand , could you show how can I run this example in multiple node(machine). Thanks ! @Edenzzzz

@Edenzzzz
Copy link
Contributor

Edenzzzz commented May 6, 2024

Thanks for your issue. This is probably due to a recent transformers upgrade, so I've fixed it.
For multi-node please refer to commands in examples/language/llama/README.md

@wxthu
Copy link
Author

wxthu commented May 6, 2024

Thanks for you reply. Actually, I have launched two Docker containers on two separate machines. How can I configure the Docker address in the host file

@Edenzzzz
Copy link
Contributor

Edenzzzz commented May 7, 2024

Please refer to similar examples in Pytorch forum. You can either run docker in host network mode or map a port from container to host.
https://discuss.pytorch.org/t/how-to-multi-node-parallel-in-dockers-container/188736
https://discuss.pytorch.org/t/run-multi-node-training-inside-docker/167537

@wxthu
Copy link
Author

wxthu commented May 7, 2024

when I run the examples in ColossalAI/examples/language/gpt/hybridparallelism/ using command bash run.sh, I always got the following error:
image

Failed to run torch 2.1 in Tesla V100 GPU .....
@Edenzzzz do you test this demo on V100 GPU , cuda 12.1, torch 2.1?

@Edenzzzz
Copy link
Contributor

Edenzzzz commented May 10, 2024

This is not a bug on our end as flash attention doesn't support V100, which is why it's throwing no kernel. You should uninstall flash_attn

@wxthu wxthu closed this as completed May 10, 2024
@wxthu
Copy link
Author

wxthu commented May 10, 2024

This is not a bug on our end as flash attention doesn't support V100, which is why it's throwing no kernel. You should uninstall flash_attn

When I uninstall the flash-attn and re-run this example , and I met the similar error.
image

How can I run this example successfully
@Edenzzzz

@wxthu wxthu reopened this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants