AMDMIGraphX icon indicating copy to clipboard operation
AMDMIGraphX copied to clipboard

Switch to c++23

Open pfultz2 opened this issue 5 months ago • 6 comments

This upgrades the version to c++23 for our source code and for kernels. We still cannot use newer std library features because sles uses gcc 7.

  • Update any_cast of type erasure to handle casting to classes that dont match the interface(I am not sure why this worked before as it seems obvious why it would fail). In this case, the any_cast member now has the constraints so it cant be called with invalid class, and the any_cast function are overloaded so if any_cast member cant be called it will return null(or throw depending on which version).
  • Disable clang tidy checks for newer c++. We can look at trying to reenable this in the future, but most of them require a newer c++ library which we cannot use because of sles. Also, the fixits for the using require keyword instead of enable_if is completely broken.
  • Disable the -Wdeprecated-this-capture warning, since it leads to too many false positives. If we fix the deprecated warning, then we usually get another warning about unused capture. We can try and address this at a later time.
  • Fix dangling references to temporary in parse_gridsample, most likely due to changes in the std::accumulate algorithm.

pfultz2 avatar Jul 21 '25 15:07 pfultz2

Since MSVC implements P0533R9 this breaks when compiling with hip. I opened issue here for the compiler team to fix this. For now, we need use c++17 on windows, but this may lead subpar workarounds until the issue is fixed.

pfultz2 avatar Jul 21 '25 18:07 pfultz2

Let me try c++20.

pfultz2 avatar Jul 21 '25 18:07 pfultz2

This whole exercise should ideally be first verified on the Windows platform.

Msvc is not as up-2-date in its support matrix for c++23 as gcc & clang. https://en.cppreference.com/w/cpp/compiler_support/23.

lakhinderwalia avatar Jul 21 '25 19:07 lakhinderwalia

Test Batch Rate new
ae7af2
Rate old
052e8f
Diff Compare
torchvision-resnet50 64 3,158.56 3,158.08 0.02% :white_check_mark:
torchvision-resnet50_fp16 64 6,593.45 6,592.78 0.01% :white_check_mark:
torchvision-densenet121 32 2,439.55 2,438.75 0.03% :white_check_mark:
torchvision-densenet121_fp16 32 4,119.25 4,130.05 -0.26% :white_check_mark:
torchvision-inceptionv3 32 1,666.20 1,665.61 0.04% :white_check_mark:
torchvision-inceptionv3_fp16 32 2,588.64 2,588.98 -0.01% :white_check_mark:
cadene-inceptionv4 16 794.47 795.18 -0.09% :white_check_mark:
cadene-resnext64x4 16 802.72 802.87 -0.02% :white_check_mark:
slim-mobilenet 64 8,210.90 8,208.93 0.02% :white_check_mark:
slim-nasnetalarge 64 221.80 221.84 -0.02% :white_check_mark:
slim-resnet50v2 64 3,297.97 3,295.13 0.09% :white_check_mark:
bert-mrpc-onnx 8 1,133.71 1,135.52 -0.16% :white_check_mark:
bert-mrpc-tf 1 488.74 488.63 0.02% :white_check_mark:
pytorch-examples-wlang-gru 1 315.46 309.76 1.84% :white_check_mark:
pytorch-examples-wlang-lstm 1 435.76 446.29 -2.36% :white_check_mark:
torchvision-resnet50_1 1 807.63 806.43 0.15% :white_check_mark:
cadene-dpn92_1 1 433.48 425.59 1.85% :white_check_mark:
cadene-resnext101_1 1 368.72 360.96 2.15% :white_check_mark:
onnx-taau-downsample 1 398.13 398.07 0.01% :white_check_mark:
dlrm-criteoterabyte 1 31.91 31.93 -0.04% :white_check_mark:
dlrm-criteoterabyte_fp16 1 50.98 51.01 -0.05% :white_check_mark:
agentmodel 1 9,706.38 9,421.43 3.02% :high_brightness:
unet_fp16 2 59.00 59.07 -0.12% :white_check_mark:
resnet50v1_fp16 1 999.50 993.23 0.63% :white_check_mark:
resnet50v1_int8 1 992.98 999.58 -0.66% :white_check_mark:
bert_base_cased_fp16 64 1,099.51 1,099.48 0.00% :white_check_mark:
bert_large_uncased_fp16 32 343.77 343.86 -0.03% :white_check_mark:
bert_large_fp16 1 198.50 197.89 0.31% :white_check_mark:
distilgpt2_fp16 16 2,075.07 2,075.60 -0.03% :white_check_mark:
yolov5s 1 589.40 588.33 0.18% :white_check_mark:
tinyllama 1 43.78 43.77 0.02% :white_check_mark:
vicuna-fastchat 1 45.06 44.80 0.58% :white_check_mark:
whisper-tiny-encoder 1 410.29 409.17 0.27% :white_check_mark:
whisper-tiny-decoder 1 414.26 413.25 0.25% :white_check_mark:
llama2_7b 1 19.12 19.11 0.05% :white_check_mark:
qwen1.5-7b 1 23.44 23.42 0.09% :white_check_mark:
phi3-3.8b 1 26.61 26.62 -0.05% :white_check_mark:
mask-rcnn 1 11.96 12.20 -1.99% :white_check_mark:
llama3-8b 1 21.68 21.68 -0.03% :white_check_mark:
whisper-large-encoder 1 10.17 10.17 0.00% :white_check_mark:
whisper-large-decoder 1 99.95 99.50 0.45% :white_check_mark:
mistral-7b 1 23.66 23.66 -0.03% :white_check_mark:
FLUX.1-schnell 1 727.86 727.11 0.10% :white_check_mark:
nan nan nan nan nan% :x:

This build is not recommended to merge :red_circle:

migraphx-bot avatar Sep 10 '25 16:09 migraphx-bot


     :white_check_mark: bert-mrpc-onnx: PASSED: MIGraphX meets tolerance
:x:bert-mrpc-tf: ERROR - check error output2025-09-10 10:38:02.763843: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 359, in
main()
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 306, in main
graph = load_tf_graph(model_name)
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 300, in load_tf_graph
graph_def.ParseFromString(f.read())
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/lib/io/file_io.py", line 116, in read
self._preread_check()
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/lib/io/file_io.py", line 77, in _preread_check
self._read_buf = _pywrap_file_io.BufferedInputStream(
tensorflow.python.framework.errors_impl.UnimplementedError: File system scheme '[local]' not implemented (file: '/new-saved-models/tf-misc/bert_mrpc1.pb')

     :white_check_mark: pytorch-examples-wlang-gru: PASSED: MIGraphX meets tolerance
     :white_check_mark: pytorch-examples-wlang-lstm: PASSED: MIGraphX meets tolerance
     :white_check_mark: dlrm-criteoterabyte: PASSED: MIGraphX meets tolerance
     :white_check_mark: agentmodel: PASSED: MIGraphX meets tolerance
     :white_check_mark: unet: PASSED: MIGraphX meets tolerance
     :white_check_mark: resnet50v1: PASSED: MIGraphX meets tolerance
     :white_check_mark: bert_base_cased_fp16: PASSED: MIGraphX meets tolerance
:red_circle:bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output

     :white_check_mark: bert_large: PASSED: MIGraphX meets tolerance
     :white_check_mark: yolov5s: PASSED: MIGraphX meets tolerance
     :white_check_mark: tinyllama: PASSED: MIGraphX meets tolerance
     :white_check_mark: vicuna-fastchat: PASSED: MIGraphX meets tolerance
     :white_check_mark: whisper-tiny-encoder: PASSED: MIGraphX meets tolerance
     :white_check_mark: whisper-tiny-decoder: PASSED: MIGraphX meets tolerance
     :white_check_mark: distilgpt2_fp16: PASSED: MIGraphX meets tolerance
     :white_check_mark: llama2_7b: PASSED: MIGraphX meets tolerance
     :white_check_mark: qwen1.5-7b: PASSED: MIGraphX meets tolerance
     :white_check_mark: phi3-3.8b: PASSED: MIGraphX meets tolerance
:red_circle:mask-rcnn: FAILED: MIGraphX is not within tolerance - check verbose output

     :white_check_mark: llama3-8b: PASSED: MIGraphX meets tolerance
     :white_check_mark: whisper-large-decoder: PASSED: MIGraphX meets tolerance
     :white_check_mark: mistral-7b: PASSED: MIGraphX meets tolerance
     :white_check_mark: FLUX.1-schnell: PASSED: MIGraphX meets tolerance

migraphx-bot avatar Sep 10 '25 16:09 migraphx-bot

@pfultz2 how urgent is this for upcoming release?

TedThemistokleous avatar Oct 01 '25 16:10 TedThemistokleous