all_reduce_e2e_test.cc
Google Test frameworkimports xla/tsl/platform/statusor.h
SHA-256367d65cb25bcee4ccc9088a8c5c405c5bb4c2390968fe5ba70e2a845ceb8af66
MaleculeMd₂(In₂Pa)
Evidence
1/* Copyright 2026 The OpenXLA Authors.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is …
11:42… IND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#include <algorithm>
17#include <cmath>
18#include <cstddef>
19#include <cstdint>
20#include <optional>
21#include <ostream>
22#include <string>
23#include <utility>
24#include <vector>
25
26#include <gmock/gmock.h>
27#include <gtest/gtest.h>
28#include "absl/algorithm/container.h"
29#include "absl/log/check.h"
30#include "absl/log/log.h"
31#include "absl/status/status.h"
32#include "absl/status/statusor.h"
33#include "absl/strings/str_cat.h"
34#include "absl/strings/str_format.h"
35#include "absl/strings/str_join.h"
36#include "absl/strings/string_view.h"
37#include "absl/types/span.h"
38#include "xla/array.h"
39#include "xla/backends/gpu/runtime/all_reduce.h"
40#include "xla/core/collectives/reduction_kind.h"
41#include "xla/error_spec.h"
42#include "xla/hlo/ir/hlo_casting_utils.h"
43#include "xla/hlo/ir/hlo_input_output_alias_config.h"
44#include "xla/hlo/ir/hlo_instruction.h"
45#include "xla/hlo/ir/hlo_instructions.h"
46#include "xla/hlo/ir/hlo_module.h"
47#include "xla/hlo/ir/hlo_opcode.h"
48#include "xla/hlo/testlib/hlo_hardware_independent_test_base.h"
49#include "xla/literal.h"
50#include "xla/literal_util.h"
51#include "xla/primitive_util.h"
52#include "xla/service/collective_ops_utils.h"
53#include "xla/service/gpu/backend_configs.pb.h"
54#include "xla/service/gpu/tests/collective_ops_e2e_test_base.h"
55#include "xla/shape.h"
56#include "xla/shape_util.h"
57#include "xla/stream_executor/gpu/all_reduce_kernel.h"
58#include "xla/tests/literal_test_util.h"
80:24… ctual_type = instr->operand(0)->shape().element_type();
81 ASSERT_EQ(actual_type, expected_type)
82 << "Expected AllReduce type " << PrimitiveType_Name(expected_type)
83 << " but …
828:6… Forward outputs should match exactly (no FP8 in forward path)
829 EXPECT_TRUE(LiteralTestUtil::Equal(f16_r0[0], f8_r0[0]));
830
831 // FP8 vs FP16 weight comparison: should be close but not identical
832 EXPECT_T …
846:62… %)
847 EXPECT_GT(max_abs_diff, 1e-3f);
848}
849
850// Test that FP8 all-reduce fails on pre-Hopper CUDA GPUs without FP8 support.
851// Note: ROCm is skipped because it has a fallback to ncclInt8 for all GPUs.
852TEST_F(AllReduceTestNoParams, AsyncAllReduce_F8E4M3FN_FailsOnUnsupportedGPUs) {
853 if (Capability().IsRocm()) {
854 GTEST_SKIP()
855 …