intel / intel-xpu-backend-for-triton

OpenAI Triton backend for Intel® GPUs
MIT License
144 stars 44 forks source link

[Accuracy] Summary for `huggingface` models failed in Inductor `training` accuracy check #423

Closed ESI-SYD closed 9 months ago

ESI-SYD commented 9 months ago

Training Accuracy check results of huggingface models based on triton 3.0.0 (3 test scenarios in total)

Test datatype: amp_bf16 amp_fp16 float32

This issue can be split into multiple work items

Failed model list:

=============================Failed models in Training mode=======================
amp_bf16:
DistilBertForQuestionAnswering (random)
AlbertForQuestionAnswering (random)
DebertaForQuestionAnswering (random)
RobertaForCausalLM (random)
T5ForConditionalGeneration (random)

BartForCausalLM ([ERROR] Accuracy failed for key name logits)
BartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MobileBertForQuestionAnswering ([ERROR] Accuracy failed for key name mobilebert.encoder.layer.14.ffn.1.intermediate.dense.bias.grad)
OPTForCausalLM ([ERROR] Accuracy failed for key name logits)
BlenderbotSmallForCausalLM ([ERROR] Accuracy failed for key name logits)
PLBartForCausalLM ([ERROR] Accuracy failed for key name logits)
MBartForCausalLM ([ERROR] Accuracy failed for key name logits)
BlenderbotSmallForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
PLBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
PegasusForCausalLM ([ERROR] Accuracy failed for key name logits)
PegasusForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
DebertaV2ForQuestionAnswering ([ERROR] Accuracy failed for key name loss)
Speech2Text2ForCausalLM ([ERROR] Accuracy failed for key name logits)
TrOCRForCausalLM ([ERROR] Accuracy failed for key name logits)
XGLMForCausalLM ([ERROR] Accuracy failed for key name logits)

amp_fp16:
DebertaForQuestionAnswering (random)
RobertaForCausalLM (random)
DistilBertForMaskedLM (random)
XLNetLMHeadModel (random)

MegatronBertForQuestionAnswering ([ERROR] Accuracy failed for key name bert.encoder.layer.8.attention.self.key.bias.grad)
BartForCausalLM ([ERROR] Accuracy failed for key name logits)
BartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MobileBertForQuestionAnswering ([ERROR] Accuracy failed for key name mobilebert.encoder.layer.12.ffn.2.intermediate.dense.bias.grad)
OPTForCausalLM ([ERROR] Accuracy failed for key name logits)
BlenderbotSmallForCausalLM ([ERROR] Accuracy failed for key name logits)
MBartForCausalLM ([ERROR] Accuracy failed for key name logits)
PLBartForCausalLM ([ERROR] Accuracy failed for key name logits)
BlenderbotSmallForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
PLBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
PegasusForCausalLM ([ERROR] Accuracy failed for key name logits)
PegasusForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
RobertaForQuestionAnswering ([ERROR] Accuracy failed for key name loss)
Speech2Text2ForCausalLM ([ERROR] Accuracy failed for key name logits)
TrOCRForCausalLM ([ERROR] Accuracy failed for key name logits)
XGLMForCausalLM ([ERROR] Accuracy failed for key name logits)

float32:
LayoutLMForSequenceClassification (random)

BartForCausalLM ([ERROR] Accuracy failed for key name logits)
BartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MobileBertForQuestionAnswering ([ERROR] Accuracy failed for key name mobilebert.encoder.layer.1.ffn.0.intermediate.dense.bias.grad)
OPTForCausalLM ([ERROR] Accuracy failed for key name logits)
PLBartForCausalLM ([ERROR] Accuracy failed for key name logits)
BlenderbotSmallForCausalLM ([ERROR] Accuracy failed for key name logits)
MBartForCausalLM ([ERROR] Accuracy failed for key name logits)
PLBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
BlenderbotSmallForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
MBartForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
PegasusForCausalLM ([ERROR] Accuracy failed for key name logits)
PegasusForConditionalGeneration ([ERROR] Accuracy failed for key name encoder_last_hidden_state)
Speech2Text2ForCausalLM ([ERROR] Accuracy failed for key name logits)
TrOCRForCausalLM ([ERROR] Accuracy failed for key name logits)
XGLMForCausalLM ([ERROR] Accuracy failed for key name logits)

Reproduce: (replace with real dtype and model)

cd /path/to/pytorch
wget -O inductor_xpu_test.sh https://raw.githubusercontent.com/intel/intel-xpu-backend-for-triton/main/.github/scripts/inductor_xpu_test.sh
pip install pandas
bash inductor_xpu_test.sh huggingface $dtype training accuracy xpu 0 static 1 0 $model

Version:

root@a4bf01946f13:/home# python collect_env.py 
Collecting environment information...
PyTorch version: 2.1.0a0+git8a1575b
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.22.1
Libc version: glibc-2.35

Python version: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-91-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:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             224
On-line CPU(s) list:                0-223
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8480+
CPU family:                         6
Model:                              143
Thread(s) per core:                 2
Core(s) per socket:                 56
Socket(s):                          2
Stepping:                           8
CPU max MHz:                        3800.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4000.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 tsc_known_freq 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 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 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 avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          5.3 MiB (112 instances)
L1i cache:                          3.5 MiB (112 instances)
L2 cache:                           224 MiB (112 instances)
L3 cache:                           210 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-55,112-167
NUMA node1 CPU(s):                  56-111,168-223
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
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] bert-pytorch==0.0.1a4
[pip3] clip-anytorch==2.6.0
[pip3] CoCa-pytorch==0.1.0
[pip3] dalle2-pytorch==1.14.2
[pip3] ema-pytorch==0.3.3
[pip3] flake8==7.0.0
[pip3] functorch==1.14.0a0+b71aa0b
[pip3] intel-extension-for-pytorch==2.1.10+git99b4297
[pip3] mypy==1.8.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.23.5
[pip3] onnx==1.15.0
[pip3] open-clip-torch==2.24.0
[pip3] pytorch-warmup==0.1.1
[pip3] rotary-embedding-torch==0.3.3
[pip3] torch==2.1.0a0+git59f7c41
[pip3] torch-fidelity==0.3.0
[pip3] torch_geometric==2.4.0
[pip3] torchaudio==2.2.0a0+02586da
[pip3] torchbench==0.1
[pip3] torchdata==0.7.1
[pip3] torchmetrics==1.0.3
[pip3] torchmultimodal==0.1.0b0
[pip3] torchrec==0.6.0
[pip3] torchtext==0.17.0a0+2c5e344
[pip3] torchvision==0.18.0a0+806dba6
[pip3] triton==3.0.0
[pip3] vector_quantize_pytorch==1.12.17
[conda] bert-pytorch              0.0.1a4                   dev_0    <develop>
[conda] blas                      1.0                         mkl  
[conda] clip-anytorch             2.6.0                    pypi_0    pypi
[conda] coca-pytorch              0.1.0                    pypi_0    pypi
[conda] dalle2-pytorch            1.14.2                   pypi_0    pypi
[conda] ema-pytorch               0.3.3                    pypi_0    pypi
[conda] functorch                 1.14.0a0+b71aa0b          pypi_0    pypi
[conda] intel-extension-for-pytorch 2.1.10+git99b4297          pypi_0    pypi
[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.23.5                   pypi_0    pypi
[conda] open-clip-torch           2.24.0                   pypi_0    pypi
[conda] pytorch-warmup            0.1.1                    pypi_0    pypi
[conda] rotary-embedding-torch    0.3.3                    pypi_0    pypi
[conda] torch                     2.1.0a0+git59f7c41          pypi_0    pypi
[conda] torch-fidelity            0.3.0                    pypi_0    pypi
[conda] torch-geometric           2.4.0                    pypi_0    pypi
[conda] torchaudio                2.2.0a0+02586da          pypi_0    pypi
[conda] torchbench                0.1                       dev_0    <develop>
[conda] torchdata                 0.7.1                    pypi_0    pypi
[conda] torchmetrics              1.0.3                    pypi_0    pypi
[conda] torchmultimodal           0.1.0b0                  pypi_0    pypi
[conda] torchrec                  0.6.0                    pypi_0    pypi
[conda] torchtext                 0.17.0a0+2c5e344          pypi_0    pypi
[conda] torchvision               0.18.0a0+806dba6          pypi_0    pypi
[conda] triton                    3.0.0                    pypi_0    pypi
[conda] vector-quantize-pytorch   1.12.17                  pypi_0    pypi

triton: https://github.com/intel/intel-xpu-backend-for-triton/commit/97ac4f91d149a3392d6e14f5d39aa4953fb6c56e

whitneywhtsang commented 9 months ago

With the following setup, all huggingface models can pass for all 3 data types (amp_bf16, amp_fp16, float32) and 2 models (inference, training):

Stonepia/pytorch    dev/triton-test-3.0 0f6d72ce16bd4b30402dcad97144d17cd7bc53ed
intel/intel-xpu-backend-for-triton  b6d3678483dbffa58f0470a46c0b512f223aabda    
intel-extension-for-pytorch 2.1.10+git99b4297       
torch                       2.1.0a0+git0f6d72c      
transformers                4.27.4      

Note:

  1. the current latest transformers version (4.38.0.dev0) causes some workloads to fail, e.g., BartForCausalLM.
  2. some workloads fail intermittently, e.g., DebertaForQuestionAnswering, GPT2ForSequenceClassification, LayoutLMForSequenceClassification, DistilBertForQuestionAnswering, RobertaForQuestionAnswering.
etiotto commented 9 months ago

With the following setup, all huggingface models can pass for all 3 data types (amp_bf16, amp_fp16, float32) and 2 models (inference, training):

Stonepia/pytorch  dev/triton-test-3.0 0f6d72ce16bd4b30402dcad97144d17cd7bc53ed
intel/intel-xpu-backend-for-triton    b6d3678483dbffa58f0470a46c0b512f223aabda    
intel-extension-for-pytorch 2.1.10+git99b4297     
torch                       2.1.0a0+git0f6d72c        
transformers                4.27.4        

Note:

  1. the current latest transformers version (4.38.0.dev0) causes some workloads to fail, e.g., BartForCausalLM.
  2. some workloads fail intermittently, e.g., DebertaForQuestionAnswering, GPT2ForSequenceClassification, LayoutLMForSequenceClassification, DistilBertForQuestionAnswering, RobertaForQuestionAnswering.

Good news! From a Triton compiler perspective this result kinda indicate the compiler is clean. How often do the intermittent failures happen?

@vlad-penkin @pbchekin I think we are ready to automate the runs for huggingface as a first step toward automating all pytorch benchmarks. Someone in the pytorch team should investigate the issue affecting BartForCausalLM with the latest transformers version (4.38.0.dev0).

etiotto commented 9 months ago

@whitneywhtsang as part of this work item can you document the exact procedure required to reproduce this result. Also please note the Triton commit used for this experiment in this issue please.

whitneywhtsang commented 9 months ago

Reproducer on x1spr cluster:

BASE=$HOME
TRITON_PROJ=$BASE/intel-xpu-backend-for-triton
PYTORCH_PROJ=$BASE/pytorch

conda create --name triton-3.0 python=3.10
conda activate triton-3.0

pip install /data/intel_extension_for_pytorch-2.1.10+git99b4297-cp310-cp310-linux_x86_64.whl

if [ ! -d "$TRITON_PROJ" ]
then
  cd $BASE
  git clone https://github.com/intel/intel-xpu-backend-for-triton.git -b llvm-target
fi
cd $TRITON_PROJ
scripts/compile-triton.sh

if [ ! -d "$PYTORCH_PROJ" ]
then
  cd $BASE
  git clone https://github.com/Stonepia/pytorch.git -b dev/triton-test-3.0
fi
cd $PYTORCH_PROJ
pip install pyyaml
make clean
python setup.py install
# Note: install the transformers version listed in https://github.com/Stonepia/pytorch/blob/dev/triton-test-3.0/.ci/docker/ci_commit_pins/huggingface.txt
# Note: the current latest transformers version (4.38.0.dev0) causes some workloads to fail, e.g., BartForCausalLM
pip install "transformers==4.27.4"
pip install pandas
# Note: `ulimit -n 1048576` may not work on some machines
cp $TRITON_PROJ/scripts/inductor_xpu_test.sh .
bash inductor_xpu_test.sh huggingface float32 training accuracy xpu 0
bash inductor_xpu_test.sh huggingface float32 inference accuracy xpu 0
bash inductor_xpu_test.sh huggingface amp_bf16 training accuracy xpu 0
bash inductor_xpu_test.sh huggingface amp_bf16 inference accuracy xpu 0
bash inductor_xpu_test.sh huggingface amp_fp16 training accuracy xpu 0
bash inductor_xpu_test.sh huggingface amp_fp16 inference accuracy xpu 0

# Expected `pip list` output:
#   triton                      3.0.0              /home/jovyan/intel-xpu-backend-for-triton/python
#   intel-extension-for-pytorch 2.1.10+git99b4297
#   torch                       2.1.0a0+git0f6d72c
#   transformers                4.27.4
whitneywhtsang commented 9 months ago

Also please note the Triton commit used for this experiment in this issue please.

It is written above in the setup.

whitneywhtsang commented 9 months ago

How often do the intermittent failures happen?

Happened once for the listed workloads for all combinations of run, and pass right away after rerun individually.

etiotto commented 9 months ago

Thanks @whitneywhtsang for the answers. I believe we can now close this one.