Skip to content

Switch to c++23 #4154

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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Switch to c++23 #4154

wants to merge 10 commits into from

Conversation

pfultz2
Copy link
Collaborator

@pfultz2 pfultz2 commented Jul 21, 2025

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.

@TedThemistokleous TedThemistokleous added the enhancement New feature or request label Jul 21, 2025
@pfultz2
Copy link
Collaborator Author

pfultz2 commented Jul 21, 2025

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
Copy link
Collaborator Author

pfultz2 commented Jul 21, 2025

Let me try c++20.

@lakhinderwalia
Copy link
Contributor

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.

@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
23e641
Rate old
3116c7
Diff Compare
torchvision-resnet50 64 3,249.85 3,245.58 0.13%
torchvision-resnet50_fp16 64 6,931.81 6,932.78 -0.01%
torchvision-densenet121 32 2,450.81 2,448.50 0.09%
torchvision-densenet121_fp16 32 4,191.94 4,194.27 -0.06%
torchvision-inceptionv3 32 1,637.01 1,637.03 -0.00%
torchvision-inceptionv3_fp16 32 2,755.96 2,751.15 0.17%
cadene-inceptionv4 16 772.01 771.02 0.13%
cadene-resnext64x4 16 814.34 813.58 0.09%
slim-mobilenet 64 7,471.59 7,467.22 0.06%
slim-nasnetalarge 64 210.95 211.05 -0.05%
slim-resnet50v2 64 3,341.23 3,341.88 -0.02%
bert-mrpc-onnx 8 1,148.49 1,146.68 0.16%
bert-mrpc-tf 1 458.72 457.83 0.19%
pytorch-examples-wlang-gru 1 347.76 335.57 3.63% 🔆
pytorch-examples-wlang-lstm 1 472.80 471.51 0.27%
torchvision-resnet50_1 1 801.40 793.95 0.94%
cadene-dpn92_1 1 415.38 413.94 0.35%
cadene-resnext101_1 1 393.41 388.08 1.37%
onnx-taau-downsample 1 396.65 396.09 0.14%
dlrm-criteoterabyte 1 33.77 33.76 0.03%
dlrm-criteoterabyte_fp16 1 51.20 51.20 -0.00%
agentmodel 1 10,404.87 10,382.46 0.22%
unet_fp16 2 60.71 60.71 -0.01%
resnet50v1_fp16 1 1,033.65 1,027.59 0.59%
resnet50v1_int8 1 1,060.73 1,031.76 2.81%
bert_base_cased_fp16 64 1,170.20 1,170.17 0.00%
bert_large_uncased_fp16 32 361.33 361.37 -0.01%
bert_large_fp16 1 203.50 202.02 0.73%
distilgpt2_fp16 16 2,241.18 2,241.01 0.01%
yolov5s 1 545.29 540.21 0.94%
tinyllama 1 44.01 43.96 0.10%
vicuna-fastchat 1 45.34 45.39 -0.13%
whisper-tiny-encoder 1 419.28 419.33 -0.01%
whisper-tiny-decoder 1 411.56 403.05 2.11%
llama2_7b 1 19.18 19.18 0.01%
qwen1.5-7b 1 23.69 23.67 0.06%
phi3-3.8b 1 26.91 26.88 0.11%
mask-rcnn 1 12.68 12.76 -0.66%
llama3-8b 1 21.83 21.84 -0.02%
whisper-large-encoder 1 10.22 10.22 0.00%
whisper-large-decoder 1 103.65 103.57 0.08%
mistral-7b 1 23.86 23.85 0.05%
FLUX.1-schnell 1 769.59 767.98 0.21%
nan nan nan nan nan%

This build is not recommended to merge 🔴

@migraphx-bot
Copy link
Collaborator


     ✅ bert-mrpc-onnx: PASSED: MIGraphX meets tolerance

❌bert-mrpc-tf: ERROR - check error outputerror: unknown warning option '-Wnrvo' [-Werror,-Wunknown-warning-option]

error: unknown warning option '-Wnrvo' [-Werror,-Wunknown-warning-option]

2025-07-21 17:00:51.974475: 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.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1753135257.270612 181744 gpu_device.cc:2022] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 62973 MB memory: -> device: 0, name: AMD Instinct MI250X/MI250, pci bus id: 0000:b3:00.0
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1753135258.132980 181744 mlir_graph_optimization_pass.cc:401] MLIR V1 optimization pass is not enabled
2025-07-21 17:01:07.653800: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.653855: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654067: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654115: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654163: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654215: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654266: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-07-21 17:01:07.654321: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
2025-07-21 17:01:07.655357: E tensorflow/compiler/mlir/tools/kernel_gen/tf_framework_c_interface.cc:228] INTERNAL: Generating device code failed.
2025-07-21 17:01:07.656485: W tensorflow/core/framework/op_kernel.cc:1829] UNKNOWN: JIT compilation failed.
2025-07-21 17:01:07.656506: I tensorflow/core/framework/local_rendezvous.cc:405] Local rendezvous is aborting with status: UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
2025-07-21 17:01:07.656517: I tensorflow/core/framework/local_rendezvous.cc:405] Local rendezvous is aborting with status: UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
2025-07-21 17:01:07.656531: I tensorflow/core/framework/local_rendezvous.cc:424] Local rendezvous recv item cancelled. Key hash: 11217777527359497193
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1407, in _do_call
return fn(*args)
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1390, in _run_fn
return self._call_tf_sessionrun(options, feed_dict, fetch_list,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1483, in _call_tf_sessionrun
return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
tensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found.
(0) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
(1) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

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 335, in main
y_out = sess.run(y, feed_dict=tf_dict)
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 977, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1220, in _run
results = self._do_run(handle, final_targets, final_fetches,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1400, in _do_run
return self._do_call(_run_fn, feeds, fetches, targets, options,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1426, in _do_call
raise type(e)(node_def, op, message) # pylint: disable=no-value-for-parameter
tensorflow.python.framework.errors_impl.UnknownError: Graph execution error:

Detected at node 'import/bert/embeddings/LayerNorm/moments/SquaredDifference' defined at (most recent call last):
Node: 'import/bert/embeddings/LayerNorm/moments/SquaredDifference'
Detected at node 'import/bert/embeddings/LayerNorm/moments/SquaredDifference' defined at (most recent call last):
Node: 'import/bert/embeddings/LayerNorm/moments/SquaredDifference'
2 root error(s) found.
(0) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
(1) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'import/bert/embeddings/LayerNorm/moments/SquaredDifference':


     ✅ pytorch-examples-wlang-gru: PASSED: MIGraphX meets tolerance

     ✅ pytorch-examples-wlang-lstm: PASSED: MIGraphX meets tolerance

     ✅ dlrm-criteoterabyte: PASSED: MIGraphX meets tolerance

     ✅ agentmodel: PASSED: MIGraphX meets tolerance

🔴unet: FAILED: MIGraphX is not within tolerance - check verbose output


     ✅ resnet50v1: PASSED: MIGraphX meets tolerance

     ✅ bert_base_cased_fp16: PASSED: MIGraphX meets tolerance

🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output


     ✅ bert_large: PASSED: MIGraphX meets tolerance

     ✅ yolov5s: PASSED: MIGraphX meets tolerance

     ✅ tinyllama: PASSED: MIGraphX meets tolerance

     ✅ vicuna-fastchat: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-encoder: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-decoder: PASSED: MIGraphX meets tolerance

     ✅ distilgpt2_fp16: PASSED: MIGraphX meets tolerance

     ✅ llama2_7b: PASSED: MIGraphX meets tolerance

     ✅ qwen1.5-7b: PASSED: MIGraphX meets tolerance

     ✅ phi3-3.8b: PASSED: MIGraphX meets tolerance

🔴mask-rcnn: FAILED: MIGraphX is not within tolerance - check verbose output


     ✅ llama3-8b: PASSED: MIGraphX meets tolerance

     ✅ whisper-large-decoder: PASSED: MIGraphX meets tolerance

     ✅ mistral-7b: PASSED: MIGraphX meets tolerance

     ✅ FLUX.1-schnell: PASSED: MIGraphX meets tolerance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants