From b7a716cb13ee56ed010820965a2c506513c9945c Mon Sep 17 00:00:00 2001 From: Samuel Reeder Date: Fri, 24 Jul 2026 16:18:06 +0000 Subject: [PATCH 1/9] fix(hipdnn): round-trip graph version in JSON --- .../tests/descriptors/TestGraphDescriptor.cpp | 65 +++++--- .../utilities/json/Graph.hpp | 20 ++- .../tests/utilities/TestJson.cpp | 148 +++++++++++++++--- 3 files changed, 185 insertions(+), 48 deletions(-) diff --git a/projects/hipdnn/backend/tests/descriptors/TestGraphDescriptor.cpp b/projects/hipdnn/backend/tests/descriptors/TestGraphDescriptor.cpp index 36c8d1f38511..f48a01326880 100644 --- a/projects/hipdnn/backend/tests/descriptors/TestGraphDescriptor.cpp +++ b/projects/hipdnn/backend/tests/descriptors/TestGraphDescriptor.cpp @@ -42,29 +42,7 @@ class TestGraphDescriptor : public ::testing::Test static void verifyGraphsEquivalent(const hipdnn_flatbuffers_sdk::data_objects::GraphT& graph1, const hipdnn_flatbuffers_sdk::data_objects::GraphT& graph2) { - EXPECT_EQ(graph1.name, graph2.name); - EXPECT_EQ(graph1.compute_data_type, graph2.compute_data_type); - EXPECT_EQ(graph1.intermediate_data_type, graph2.intermediate_data_type); - EXPECT_EQ(graph1.io_data_type, graph2.io_data_type); - EXPECT_EQ(graph1.preferred_engine_id, graph2.preferred_engine_id); - - ASSERT_EQ(graph1.tensors.size(), graph2.tensors.size()); - for(size_t i = 0; i < graph1.tensors.size(); ++i) - { - SCOPED_TRACE("tensor[" + std::to_string(i) + "]"); - ASSERT_NE(graph1.tensors[i], nullptr); - ASSERT_NE(graph2.tensors[i], nullptr); - EXPECT_EQ(*graph1.tensors[i], *graph2.tensors[i]); - } - - ASSERT_EQ(graph1.nodes.size(), graph2.nodes.size()); - for(size_t i = 0; i < graph1.nodes.size(); ++i) - { - SCOPED_TRACE("node[" + std::to_string(i) + "]"); - ASSERT_NE(graph1.nodes[i], nullptr); - ASSERT_NE(graph2.nodes[i], nullptr); - EXPECT_EQ(*graph1.nodes[i], *graph2.nodes[i]); - } + EXPECT_EQ(graph1, graph2); } }; @@ -323,6 +301,47 @@ TEST_F(TestGraphDescriptor, JsonRoundTripViaDescriptorApi) verifyGraphsEquivalent(*graph1, *graph2); } +TEST_F(TestGraphDescriptor, JsonRoundTripPreservesMinimumApiVersionAndRuntimePassByValue) +{ + using namespace hipdnn_flatbuffers_sdk::data_objects; + + auto builder = createValidGraph(); + const auto* graph = GetGraph(builder.GetBufferPointer()); + auto graphT = std::unique_ptr(graph->UnPack()); + ASSERT_NE(graphT, nullptr); + ASSERT_FALSE(graphT->tensors.empty()); + + graphT->tensors.front()->is_runtime_pass_by_value = true; + graphT->min_required_engine_api_version = std::make_unique(1, 2, 0); + + flatbuffers::FlatBufferBuilder versionedBuilder; + versionedBuilder.Finish(Graph::Pack(versionedBuilder, graphT.get())); + + GraphDescriptor original; + original.deserializeGraph(versionedBuilder.GetBufferPointer(), versionedBuilder.GetSize()); + original.buildSerializedGraph(); + + const auto jsonStr = original.getSerializedJsonGraph(); + const auto parsed = nlohmann::json::parse(jsonStr); + EXPECT_EQ(parsed.at("min_required_engine_api_version"), + nlohmann::json({{"major", 1}, {"minor", 2}, {"patch", 0}})); + + GraphDescriptor roundTripped; + ASSERT_NO_THROW( + GraphDescriptor::createFromJsonGraph(roundTripped, jsonStr.c_str(), jsonStr.size())); + roundTripped.buildSerializedGraph(); + + const auto binary = roundTripped.getSerializedGraph(); + const auto restored = UnPackGraph(static_cast(binary.ptr)); + ASSERT_NE(restored, nullptr); + ASSERT_NE(restored->min_required_engine_api_version, nullptr); + EXPECT_EQ(restored->min_required_engine_api_version->major(), 1); + EXPECT_EQ(restored->min_required_engine_api_version->minor(), 2); + EXPECT_EQ(restored->min_required_engine_api_version->patch(), 0); + ASSERT_FALSE(restored->tensors.empty()); + EXPECT_TRUE(restored->tensors.front()->is_runtime_pass_by_value); +} + TEST_F(TestGraphDescriptor, JsonSerializationEmitsOverrideShapeTrue) { auto builder = createValidGraph(); diff --git a/projects/hipdnn/flatbuffers_sdk/include/hipdnn_flatbuffers_sdk/utilities/json/Graph.hpp b/projects/hipdnn/flatbuffers_sdk/include/hipdnn_flatbuffers_sdk/utilities/json/Graph.hpp index 03f37ebac03c..ba21303a2c76 100644 --- a/projects/hipdnn/flatbuffers_sdk/include/hipdnn_flatbuffers_sdk/utilities/json/Graph.hpp +++ b/projects/hipdnn/flatbuffers_sdk/include/hipdnn_flatbuffers_sdk/utilities/json/Graph.hpp @@ -151,6 +151,11 @@ inline void to_json(nlohmann::json& graphJson, const data_objects::Graph& graph) { graphJson["preferred_engine_id"] = graph.preferred_engine_id().value(); } + if(const auto* version = graph.min_required_engine_api_version()) + { + graphJson["min_required_engine_api_version"] = { + {"major", version->major()}, {"minor", version->minor()}, {"patch", version->patch()}}; + } } } @@ -237,6 +242,18 @@ inline auto to(flatbuffers::FlatBufferBuilder& builder, } const bool isOverrideShapeEnabled = entry.value("is_override_shape_enabled", false); + const data_objects::EngineApiVersion* minRequiredEngineApiVersion = nullptr; + data_objects::EngineApiVersion parsedMinRequiredEngineApiVersion; + if(entry.contains("min_required_engine_api_version")) + { + const auto& version = entry.at("min_required_engine_api_version"); + parsedMinRequiredEngineApiVersion + = data_objects::EngineApiVersion(version.at("major").get(), + version.at("minor").get(), + version.at("patch").get()); + minRequiredEngineApiVersion = &parsedMinRequiredEngineApiVersion; + } + auto nodes = toVector(builder, entry.at("nodes")); auto tensors = toVector(builder, entry.at("tensors")); return data_objects::CreateGraphDirect(builder, @@ -247,7 +264,8 @@ inline auto to(flatbuffers::FlatBufferBuilder& builder, &tensors, &nodes, preferredEngineId, - isOverrideShapeEnabled); + isOverrideShapeEnabled, + minRequiredEngineApiVersion); } } diff --git a/projects/hipdnn/flatbuffers_sdk/tests/utilities/TestJson.cpp b/projects/hipdnn/flatbuffers_sdk/tests/utilities/TestJson.cpp index c0118202740f..7abe1d45d536 100644 --- a/projects/hipdnn/flatbuffers_sdk/tests/utilities/TestJson.cpp +++ b/projects/hipdnn/flatbuffers_sdk/tests/utilities/TestJson.cpp @@ -31,30 +31,11 @@ void toJsonAndBackTestSuite(const hipdnn_flatbuffers_sdk::data_objects::Graph* g builder.Finish(newGraphBuilder); auto newGraph = hipdnn_flatbuffers_sdk::data_objects::GetGraph(builder.GetBufferPointer()); - EXPECT_EQ(graph->compute_data_type(), newGraph->compute_data_type()) << context; - EXPECT_EQ(graph->intermediate_data_type(), newGraph->intermediate_data_type()) << context; - EXPECT_EQ(graph->io_data_type(), newGraph->io_data_type()) << context; - EXPECT_EQ(graph->name()->str(), newGraph->name()->str()) << context; - - ASSERT_EQ(graph->tensors()->size(), newGraph->tensors()->size()) << context; - auto t1 = graph->tensors()->begin(); - auto t2 = newGraph->tensors()->begin(); - for(; t1 != graph->tensors()->end() && t2 != newGraph->tensors()->end(); t1++, t2++) - { - const std::unique_ptr t1ptr(t1->UnPack()); - const std::unique_ptr t2ptr(t2->UnPack()); - EXPECT_EQ(*t1ptr, *t2ptr) << context; - } - - ASSERT_EQ(graph->nodes()->size(), newGraph->nodes()->size()) << context; - auto n1 = graph->nodes()->begin(); - auto n2 = newGraph->nodes()->begin(); - for(; n1 != graph->nodes()->end() && n2 != newGraph->nodes()->end(); n1++, n2++) - { - const std::unique_ptr n1ptr(n1->UnPack()); - const std::unique_ptr n2ptr(n2->UnPack()); - EXPECT_EQ(*n1ptr, *n2ptr) << context; - } + const std::unique_ptr graphObject(graph->UnPack()); + const std::unique_ptr newGraphObject(newGraph->UnPack()); + ASSERT_NE(graphObject, nullptr) << context; + ASSERT_NE(newGraphObject, nullptr) << context; + EXPECT_EQ(*graphObject, *newGraphObject) << context; } } // namespace @@ -189,6 +170,77 @@ TEST(TestJson, GraphToJsonAndBack) } } +TEST(TestJson, GraphVersionSerializesToJson) +{ + flatbuffers::FlatBufferBuilder builder; + const EngineApiVersion version(1, 2, 0); + const auto graphOffset = CreateGraphDirect(builder, + "graph", + DataType::FLOAT, + DataType::FLOAT, + DataType::FLOAT, + nullptr, + nullptr, + flatbuffers::nullopt, + false, + &version); + builder.Finish(graphOffset); + + const auto* graph = GetGraph(builder.GetBufferPointer()); + const nlohmann::json graphJson = *graph; + + ASSERT_TRUE(graphJson.contains("min_required_engine_api_version")); + EXPECT_EQ(graphJson.at("min_required_engine_api_version"), + nlohmann::json({{"major", 1}, {"minor", 2}, {"patch", 0}})); +} + +TEST(TestJson, GraphVersionRoundTripsFromJson) +{ + const nlohmann::json graphJson + = {{"name", "graph"}, + {"compute_data_type", DataType::FLOAT}, + {"io_data_type", DataType::FLOAT}, + {"intermediate_data_type", DataType::FLOAT}, + {"nodes", nlohmann::json::array()}, + {"tensors", nlohmann::json::array()}, + {"min_required_engine_api_version", {{"major", 1}, {"minor", 2}, {"patch", 0}}}}; + + flatbuffers::FlatBufferBuilder builder; + const auto graphOffset = hipdnn_flatbuffers_sdk::json::to(builder, graphJson); + builder.Finish(graphOffset); + + const auto* graph = GetGraph(builder.GetBufferPointer()); + const auto* version = graph->min_required_engine_api_version(); + ASSERT_NE(version, nullptr); + EXPECT_EQ(version->major(), 1); + EXPECT_EQ(version->minor(), 2); + EXPECT_EQ(version->patch(), 0); + + const nlohmann::json roundTrippedJson = *graph; + EXPECT_EQ(roundTrippedJson.at("min_required_engine_api_version"), + graphJson.at("min_required_engine_api_version")); +} + +TEST(TestJson, GraphWithoutVersionRoundTripsWithVersionAbsent) +{ + const nlohmann::json graphJson = {{"name", "graph"}, + {"compute_data_type", DataType::FLOAT}, + {"io_data_type", DataType::FLOAT}, + {"intermediate_data_type", DataType::FLOAT}, + {"nodes", nlohmann::json::array()}, + {"tensors", nlohmann::json::array()}}; + + flatbuffers::FlatBufferBuilder builder; + const auto graphOffset = hipdnn_flatbuffers_sdk::json::to(builder, graphJson); + builder.Finish(graphOffset); + + const auto* graph = GetGraph(builder.GetBufferPointer()); + EXPECT_EQ(graph->min_required_engine_api_version(), nullptr); + + const nlohmann::json roundTrippedJson = *graph; + EXPECT_FALSE(roundTrippedJson.contains("min_required_engine_api_version")); +} + namespace { @@ -467,4 +519,52 @@ TEST(TestJson, TensorAttributesLegacyJsonMissingAlignmentDefaultsTo16) EXPECT_EQ(attr->alignment(), 16); } +TEST(TestJson, TensorAttributesRuntimePassByValueRoundTrips) +{ + flatbuffers::FlatBufferBuilder builder; + const std::vector dims = {1}; + const std::vector strides = {1}; + const auto attrOffset = CreateTensorAttributesDirect(builder, + /*uid*/ 7, + /*name*/ "runtime_scalar", + DataType::FLOAT, + &strides, + &dims, + /*virtual*/ false, + TensorValue::NONE, + 0, + /*is_runtime_pass_by_value*/ true); + builder.Finish(attrOffset); + + const auto* attr = flatbuffers::GetRoot(builder.GetBufferPointer()); + const nlohmann::json attrJson = *attr; + ASSERT_TRUE(attrJson.at("is_runtime_pass_by_value").get()); + + flatbuffers::FlatBufferBuilder roundTripBuilder; + const auto newAttrOffset + = hipdnn_flatbuffers_sdk::json::to(roundTripBuilder, attrJson); + roundTripBuilder.Finish(newAttrOffset); + + const auto* newAttr + = flatbuffers::GetRoot(roundTripBuilder.GetBufferPointer()); + EXPECT_TRUE(newAttr->is_runtime_pass_by_value()); +} + +TEST(TestJson, TensorAttributesWithoutRuntimePassByValueDefaultsFalse) +{ + const nlohmann::json attrJson = {{"uid", 7}, + {"name", "legacy_tensor"}, + {"data_type", DataType::FLOAT}, + {"strides", {1}}, + {"dims", {1}}, + {"virtual", false}}; + + flatbuffers::FlatBufferBuilder builder; + const auto attrOffset = hipdnn_flatbuffers_sdk::json::to(builder, attrJson); + builder.Finish(attrOffset); + + const auto* attr = flatbuffers::GetRoot(builder.GetBufferPointer()); + EXPECT_FALSE(attr->is_runtime_pass_by_value()); +} + #endif // HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB From 59f6359124117f67cba8e7bea0a33b9263213997 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Mon, 20 Jul 2026 11:05:37 -0600 Subject: [PATCH 2/9] test(hipdnn): add runtime pass-by-value scalar integration test bundles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Providers that update to support runtime pass-by-value scalars may incorrectly claim support and produce wrong output if they ignore the runtime value and fall back to a baked-in compile-time default. This adds integration test bundles that expose that failure mode. Each bundle uses the runtime-with-default form: the scalar tensor carries is_runtime_pass_by_value=true alongside a compile-time default chosen to differ from the correct runtime value. A provider that falls back to the compile-time default produces output that diverges from the CPU reference. Synthesis fills the runtime scalar and the CPU reference executor verifies the output. The CPU reference executor (SdpaFwdPlan) is extended to read the attention scale from the variantPack when attn_scale_value is absent from node attributes, enabling it to generate correct golden data for the runtime-scale SDPA bundles. Coverage added (integration_test_bundles/quick/): - PointwiseFwdRuntimeScalar/{Add,Mul}/Small: binary pointwise with runtime scalar, compile-time defaults 0.0 (ADD) and 1.0 (MUL) - BatchnormFwdInferenceRuntimeScalar/Epsilon/Small: negative test — frontend correctly rejects runtime epsilon via validateScalarParameter - BatchnormFwdTrainingRuntimeScalar/Small: forward training with runtime momentum, compile-time default 0.5 - SdpaFwdRuntimeScale/bhsd/{bf16,fp16,fp8}/...: runtime attention scale across all 13 existing SdpaFwd compile-time bundle variants (hd128/hd192, nomask/causal, batch/group/stats), compile-time bake-in 2.0 with attn_scale_value null ALMIOPEN-2267 --- .../Epsilon/Small/Small.json | 146 ++++ .../Epsilon/Small/Small.meta.json | 26 + .../Small/Small.json | 241 ++++++ .../Small/Small.meta.json | 16 + .../Add/Small/Small.json | 58 ++ .../Add/Small/Small.meta.json | 16 + .../Mul/Small/Small.json | 58 ++ .../Mul/Small/Small.meta.json | 16 + .../bhsd/bf16/Small/Small.json | 105 +++ .../bhsd/bf16/Small/Small.meta.json | 21 + .../bf16/hd128_causal_batch/Small/Small.json | 149 ++++ .../hd128_causal_batch/Small/Small.meta.json | 9 + .../bf16/hd128_causal_group/Small/Small.json | 173 +++++ .../hd128_causal_group/Small/Small.meta.json | 9 + .../bf16/hd128_nomask_batch/Small/Small.json | 149 ++++ .../hd128_nomask_batch/Small/Small.meta.json | 9 + .../SmallStats/SmallStats.json | 167 +++++ .../SmallStats/SmallStats.meta.json | 9 + .../bf16/hd128_nomask_group/Small/Small.json | 173 +++++ .../hd128_nomask_group/Small/Small.meta.json | 9 + .../bf16/hd192_causal_batch/Small/Small.json | 149 ++++ .../hd192_causal_batch/Small/Small.meta.json | 9 + .../bf16/hd192_nomask_batch/Small/Small.json | 149 ++++ .../hd192_nomask_batch/Small/Small.meta.json | 9 + .../fp16/hd128_causal_batch/Small/Small.json | 149 ++++ .../hd128_causal_batch/Small/Small.meta.json | 9 + .../fp16/hd128_nomask_batch/Small/Small.json | 149 ++++ .../hd128_nomask_batch/Small/Small.meta.json | 9 + .../SmallStats/SmallStats.json | 167 +++++ .../SmallStats/SmallStats.meta.json | 9 + .../fp16/hd192_causal_batch/Small/Small.json | 149 ++++ .../hd192_causal_batch/Small/Small.meta.json | 9 + .../fp16/hd192_nomask_batch/Small/Small.json | 149 ++++ .../hd192_nomask_batch/Small/Small.meta.json | 9 + .../fp8/hd128_causal_batch/Small/Small.json | 185 +++++ .../hd128_causal_batch/Small/Small.meta.json | 9 + .../fp8/hd128_causal_group/Small/Small.json | 209 ++++++ .../hd128_causal_group/Small/Small.meta.json | 9 + .../fp8/hd128_nomask_batch/Small/Small.json | 185 +++++ .../hd128_nomask_batch/Small/Small.meta.json | 9 + ...enerate_batchnorm_runtime_scalar_golden.py | 691 ++++++++++++++++++ ...enerate_pointwise_runtime_scalar_golden.py | 329 +++++++++ .../generate_sdpa_runtime_scale_golden.py | 418 +++++++++++ .../cpu_graph_executor/TestSdpaFwdPlan.cpp | 2 + 44 files changed, 4729 insertions(+) create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py create mode 100644 dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py create mode 100644 dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json new file mode 100644 index 000000000000..97ac5cfbd455 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json @@ -0,0 +1,146 @@ +{ + "nodes": [ + { + "type": "BatchnormInferenceAttributesVarianceExt", + "compute_data_type": "float", + "name": "", + "inputs": { + "x_tensor_uid": 0, + "mean_tensor_uid": 1, + "variance_tensor_uid": 2, + "scale_tensor_uid": 3, + "bias_tensor_uid": 4, + "epsilon_tensor_uid": 5 + }, + "outputs": { + "y_tensor_uid": 6 + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "x", + "dims": [ + 2, + 3, + 4, + 5 + ], + "strides": [ + 60, + 20, + 5, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 1, + "name": "mean", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 2, + "name": "variance", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 3, + "name": "scale", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 4, + "name": "bias", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 5, + "name": "epsilon", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 6, + "name": "y", + "dims": [ + 2, + 3, + 4, + 5 + ], + "strides": [ + 60, + 20, + 5, + 1 + ], + "data_type": "float", + "virtual": false + } + ], + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json new file mode 100644 index 000000000000..e620083ab219 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json @@ -0,0 +1,26 @@ +{ + "format_version": 1, + "operation": "BatchnormFwdInferenceRuntimeScalar/Epsilon", + "generator": "generate_batchnorm_runtime_scalar_golden.py", + "generator_sha256": "e24401f1082a3b59972afc589bcd538e61eff52adc3fd57f307ab5e7d45c6d0d", + "generator_version": "1.1.0", + "generated_at": "2026-07-17T22:22:44Z", + "reference_source": "PyTorch 2.12.0+rocm7.2", + "reference_strategy": "pytorch_bn_inference_variance_ext", + "rocm_version": "", + "seed": 42, + "notes": "NEGATIVE TEST: epsilon (uid=5) is a runtime tensor (no value_type/value fields). hipDNN's validateScalarParameter requires epsilon to be pass_by_value==true, so validate() must return INVALID_VALUE. Golden output is computed with correct epsilon=1e-5. Detection value=1.0 is intentionally far from 1e-5: a broken provider that bypasses validation and executes with the wrong epsilon will produce output that diverges from the golden data.", + "config": { + "scalar": "epsilon", + "x_dims": [ + 2, + 3, + 4, + 5 + ], + "scalar_uid": 5, + "scalar_value": 1.0, + "correct_epsilon": 1e-05, + "expected_failure": "validate" + } +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json new file mode 100644 index 000000000000..598bc80e293e --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json @@ -0,0 +1,241 @@ +{ + "nodes": [ + { + "type": "BatchnormAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "x_tensor_uid": 0, + "scale_tensor_uid": 1, + "bias_tensor_uid": 2, + "epsilon_tensor_uid": 3, + "peer_stats_tensor_uid": [], + "prev_running_mean_tensor_uid": 4, + "prev_running_variance_tensor_uid": 5, + "momentum_tensor_uid": 6 + }, + "outputs": { + "y_tensor_uid": 7, + "mean_tensor_uid": 8, + "inv_variance_tensor_uid": 9, + "next_running_mean_tensor_uid": 10, + "next_running_variance_tensor_uid": 11 + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "x", + "dims": [ + 2, + 3, + 4, + 5 + ], + "strides": [ + 60, + 20, + 5, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 1, + "name": "scale", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 2, + "name": "bias", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 3, + "name": "epsilon", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "value_type": "Float32Value", + "value": 1e-05 + }, + { + "uid": 4, + "name": "prev_running_mean", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 5, + "name": "prev_running_var", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 6, + "name": "momentum", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 0.5 + }, + { + "uid": 7, + "name": "y", + "dims": [ + 2, + 3, + 4, + 5 + ], + "strides": [ + 60, + 20, + 5, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 8, + "name": "mean_out", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 9, + "name": "inv_var_out", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "next_running_mean", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 11, + "name": "next_running_var", + "dims": [ + 1, + 3, + 1, + 1 + ], + "strides": [ + 3, + 1, + 1, + 1 + ], + "data_type": "float", + "virtual": false + } + ], + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json new file mode 100644 index 000000000000..986d18c5934f --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "operation": "BatchnormFwdTrainingRuntimeScalar/Momentum", + "generator": "generate_batchnorm_runtime_scalar_golden.py", + "generator_sha256": "e24401f1082a3b59972afc589bcd538e61eff52adc3fd57f307ab5e7d45c6d0d", + "generator_version": "1.1.0", + "generated_at": "2026-07-17T22:22:46Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scalar bundle: momentum (uid=6) has is_runtime_pass_by_value=true with compile-time default value=0.5. Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (0.5) instead of the runtime value produces diverging output.", + "config": { + "scalar": "momentum", + "x_dims": [2, 3, 4, 5], + "scalar_uid": 6, + "compile_time_default": 0.5 + } +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json new file mode 100644 index 000000000000..a29de3eb2f3c --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json @@ -0,0 +1,58 @@ +{ + "nodes": [ + { + "type": "PointwiseAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "operation": "add", + "in_0_tensor_uid": 0, + "in_1_tensor_uid": 1, + "in_2_tensor_uid": null, + "axis_tensor_uid": null, + "relu_lower_clip": null, + "relu_upper_clip": null, + "relu_lower_clip_slope": null, + "swish_beta": null, + "elu_alpha": null, + "softplus_beta": null + }, + "outputs": { + "out_0_tensor_uid": 2 + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "in0", + "dims": [2, 4, 6, 8], + "strides": [192, 48, 8, 1], + "data_type": "float", + "virtual": false + }, + { + "uid": 1, + "name": "scalar", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 0.0 + }, + { + "uid": 2, + "name": "out0", + "dims": [2, 4, 6, 8], + "strides": [192, 48, 8, 1], + "data_type": "float", + "virtual": false + } + ], + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json new file mode 100644 index 000000000000..3009ea13ebab --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "operation": "PointwiseFwdRuntimeScalar/ADD", + "generator": "generate_pointwise_runtime_scalar_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scalar bundle: in_1 (uid=1) has is_runtime_pass_by_value=true with compile-time default value=0.0 (additive identity). Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (0.0) instead of the runtime value produces diverging output.", + "config": { + "operation": "add", + "dims": [2, 4, 6, 8], + "dtype": "float", + "scalar_uid": 1, + "compile_time_default": 0.0 + } +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json new file mode 100644 index 000000000000..f8789f2bec21 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json @@ -0,0 +1,58 @@ +{ + "nodes": [ + { + "type": "PointwiseAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "operation": "mul", + "in_0_tensor_uid": 0, + "in_1_tensor_uid": 1, + "in_2_tensor_uid": null, + "axis_tensor_uid": null, + "relu_lower_clip": null, + "relu_upper_clip": null, + "relu_lower_clip_slope": null, + "swish_beta": null, + "elu_alpha": null, + "softplus_beta": null + }, + "outputs": { + "out_0_tensor_uid": 2 + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "in0", + "dims": [2, 4, 6, 8], + "strides": [192, 48, 8, 1], + "data_type": "float", + "virtual": false + }, + { + "uid": 1, + "name": "scalar", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 1.0 + }, + { + "uid": 2, + "name": "out0", + "dims": [2, 4, 6, 8], + "strides": [192, 48, 8, 1], + "data_type": "float", + "virtual": false + } + ], + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json new file mode 100644 index 000000000000..cae1956e94b6 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "operation": "PointwiseFwdRuntimeScalar/MUL", + "generator": "generate_pointwise_runtime_scalar_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scalar bundle: in_1 (uid=1) has is_runtime_pass_by_value=true with compile-time default value=1.0 (multiplicative identity). Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (1.0) instead of the runtime value produces diverging output.", + "config": { + "operation": "mul", + "dims": [2, 4, 6, 8], + "dtype": "float", + "scalar_uid": 1, + "compile_time_default": 1.0 + } +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json new file mode 100644 index 000000000000..7495fd9fa5c8 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json @@ -0,0 +1,105 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [2, 4, 256, 128], + "strides": [131072, 32768, 128, 1], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [2, 4, 256, 128], + "strides": [131072, 32768, 128, 1], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [2, 4, 256, 128], + "strides": [131072, 32768, 128, 1], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [2, 4, 256, 128], + "strides": [131072, 32768, 128, 1], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json new file mode 100644 index 000000000000..c9877970814b --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json @@ -0,0 +1,21 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.1.0", + "generated_at": "2026-07-21T00:00:00Z", + "reference_source": "PyTorch 2.12.0+rocm7.2", + "reference_backend": "pytorch_math_backend", + "rocm_version": "", + "seed": 42, + "notes": "Runtime-with-default scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The runtime detection value is 1/sqrt(128)=0.08838834764831843 (matching the existing SdpaFwd/bhsd/bf16/hd128_nomask_batch golden data). A provider that ignores the runtime value and uses the compile-time default (2.0) produces output that diverges from the golden data.", + "config": { + "q_dims": [2, 4, 256, 128], + "v_dims": [2, 4, 256, 128], + "dtype": "bf16", + "scale_uid": 4, + "scale_value": 0.08838834764831843, + "compile_time_default": 2.0, + "gqa_ratio": 1 + } +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json new file mode 100644 index 000000000000..dfa92e299deb --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json new file mode 100644 index 000000000000..9dfbe1ebf674 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json @@ -0,0 +1,173 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": 5, + "seq_len_kv_tensor_uid": 6, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + }, + { + "uid": 5, + "name": "SeqLenQ", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + }, + { + "uid": 6, + "name": "SeqLenKv", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json new file mode 100644 index 000000000000..06c76f1d1433 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json new file mode 100644 index 000000000000..d0b67673c527 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -0,0 +1,167 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 10, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": 4, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": true, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "LSE", + "dims": [ + 2, + 4, + 256, + 1 + ], + "strides": [ + 1024, + 256, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json new file mode 100644 index 000000000000..2f3f3e4af1ec --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json @@ -0,0 +1,173 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": 5, + "seq_len_kv_tensor_uid": 6, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + }, + { + "uid": 5, + "name": "SeqLenQ", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + }, + { + "uid": 6, + "name": "SeqLenKv", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json new file mode 100644 index 000000000000..c140170b18b2 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json new file mode 100644 index 000000000000..fae7e2719f63 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json new file mode 100644 index 000000000000..260619bed373 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "half", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json new file mode 100644 index 000000000000..8bbf6ea2482d --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "half", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json new file mode 100644 index 000000000000..17411785d42f --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -0,0 +1,167 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 10, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": 4, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": true, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 4, + "name": "LSE", + "dims": [ + 2, + 4, + 256, + 1 + ], + "strides": [ + 1024, + 256, + 1, + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "half", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json new file mode 100644 index 000000000000..360ab3a25602 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "half", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json new file mode 100644 index 000000000000..5120a5266efa --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json @@ -0,0 +1,149 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 4, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": null, + "descale_k_tensor_uid": null, + "descale_v_tensor_uid": null, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 192 + ], + "strides": [ + 196608, + 49152, + 192, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "half", + "virtual": false + }, + { + "uid": 4, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "half", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json new file mode 100644 index 000000000000..5f05cea6838d --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json @@ -0,0 +1,185 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 10, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": 7, + "descale_k_tensor_uid": 8, + "descale_v_tensor_uid": 9, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 7, + "name": "DescaleQ", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 8, + "name": "DescaleK", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 9, + "name": "DescaleV", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json new file mode 100644 index 000000000000..371522451039 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json @@ -0,0 +1,209 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 10, + "seq_len_q_tensor_uid": 5, + "seq_len_kv_tensor_uid": 6, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": 7, + "descale_k_tensor_uid": 8, + "descale_v_tensor_uid": 9, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": true, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": -1, + "right_bound": 0, + "max_seq_len_kv": null, + "diagonal_alignment": "BOTTOM_RIGHT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 3, + 4, + 512, + 128 + ], + "strides": [ + 262144, + 65536, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 5, + "name": "SeqLenQ", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + }, + { + "uid": 6, + "name": "SeqLenKv", + "dims": [ + 4 + ], + "strides": [ + 1 + ], + "data_type": "int32", + "virtual": false + }, + { + "uid": 7, + "name": "DescaleQ", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 8, + "name": "DescaleK", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 9, + "name": "DescaleV", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json new file mode 100644 index 000000000000..99c862327f9b --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json @@ -0,0 +1,185 @@ +{ + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": 0, + "k_tensor_uid": 1, + "v_tensor_uid": 2, + "attn_mask_tensor_uid": null, + "scale_tensor_uid": 10, + "seq_len_q_tensor_uid": null, + "seq_len_kv_tensor_uid": null, + "seed_tensor_uid": null, + "offset_tensor_uid": null, + "dropout_mask_tensor_uid": null, + "dropout_scale_tensor_uid": null, + "page_table_k_tensor_uid": null, + "page_table_v_tensor_uid": null, + "block_mask_tensor_uid": null, + "sink_token_tensor_uid": null, + "descale_q_tensor_uid": 7, + "descale_k_tensor_uid": 8, + "descale_v_tensor_uid": 9, + "descale_s_tensor_uid": null, + "scale_s_tensor_uid": null, + "scale_o_tensor_uid": null + }, + "outputs": { + "o_tensor_uid": 3, + "stats_tensor_uid": null, + "max_tensor_uid": null, + "sum_exp_tensor_uid": null, + "rng_dump_tensor_uid": null, + "amax_s_tensor_uid": null, + "amax_o_tensor_uid": null + }, + "attributes": { + "generate_stats": null, + "alibi_mask": false, + "padding_mask": false, + "causal_mask": false, + "causal_mask_bottom_right": false, + "dropout_probability": null, + "attn_scale_value": null, + "left_bound": null, + "right_bound": null, + "max_seq_len_kv": null, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO" + } + } + ], + "tensors": [ + { + "uid": 0, + "name": "Q", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 1, + "name": "K", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 2, + "name": "V", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "fp8_e4m3", + "virtual": false + }, + { + "uid": 3, + "name": "O", + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], + "data_type": "bfloat16", + "virtual": false + }, + { + "uid": 7, + "name": "DescaleQ", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 8, + "name": "DescaleK", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 9, + "name": "DescaleV", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true, + "value_type": "Float32Value", + "value": 2.0 + } + ], + "io_data_type": "bfloat16", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "" +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json new file mode 100644 index 000000000000..30b48509b7f1 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json @@ -0,0 +1,9 @@ +{ + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_version": "1.0.0", + "generated_at": "2026-07-17T15:48:00Z", + "reference_source": "synthesis+cpu_reference", + "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." +} diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py new file mode 100644 index 000000000000..ca098a4ffdb4 --- /dev/null +++ b/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py @@ -0,0 +1,691 @@ +#!/usr/bin/env python3 +# Copyright © Advanced Micro Devices, Inc., or its affiliates. +# SPDX-License-Identifier: MIT +""" +Batchnorm Runtime Scalar Golden Reference Bundle Generator + +Generates pre-computed reference data for batchnorm operations where a +scalar (epsilon or momentum) is provided as a runtime pass-by-value tensor +(dims=[1], strides=[1]) rather than a compile-time baked value. + +Supported scalars: + epsilon — BN inference with variance_ext; frontend REJECTS runtime epsilon + (validateScalarParameter enforces pass_by_value==true for epsilon). + This generates a NEGATIVE test bundle: the graph JSON is valid to + parse, but validate() will return INVALID_VALUE. No golden tensor + data is written for this case. + momentum — BN forward training; frontend accepts a runtime momentum tensor. + A detection value far from the compile-time default (0.5f) is used. + +Output for momentum: {base_filename}.json + .tensor{uid}.bin + .meta.json +Output for epsilon: {base_filename}.json + .meta.json (no .bin — negative test) + +Usage: + # Momentum (positive test — generates golden output) + python generate_batchnorm_runtime_scalar_golden.py \\ + --base-filename bundles/BatchnormFwdTrainingRuntimeScalar/Momentum/Small/Small \\ + --scalar momentum --scalar-value 0.9 --size 2 3 4 5 --seed 42 + + # Epsilon (negative test — generates graph JSON only, no golden output) + python generate_batchnorm_runtime_scalar_golden.py \\ + --base-filename bundles/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small \\ + --scalar epsilon --scalar-value 1.0 --size 2 3 4 5 --seed 42 +""" + +import argparse +import datetime +import hashlib +import json +import os +import sys + +import torch +import torch.nn.functional as F + +# Bump when generator logic changes in a way that affects output data. +# 1.0.0 — Initial: BN momentum (positive) and epsilon (negative) runtime scalar bundles +# 1.1.0 — Epsilon bundle now writes golden .bin files; mean_out/inv_var_out derived +# from execute_batchnorm_fwd_training (not recomputed independently) +GENERATOR_VERSION = "1.1.0" + + +def compute_contiguous_strides(dims): + strides = [] + stride = 1 + for d in reversed(dims): + strides.append(stride) + stride *= d + strides.reverse() + return strides + + +def save_tensor_bin(tensor, path): + t = tensor.contiguous().cpu().float() + raw = t.numpy().tobytes() + with open(path, "wb") as f: + f.write(raw) + + +def _get_generator_sha256(): + script_path = os.path.abspath(__file__) + with open(script_path, "rb") as f: + return hashlib.sha256(f.read()).hexdigest() + + +# --------------------------------------------------------------------------- +# Epsilon bundle (negative test — no golden output) +# --------------------------------------------------------------------------- + + +def build_epsilon_graph_json(x_dims): + """BN inference (variance_ext style) with epsilon as a runtime tensor. + + The frontend's validateScalarParameter will reject this graph at validate() + time with INVALID_VALUE because epsilon must be pass_by_value==true. + No golden tensor output is generated. + + Tensor UIDs: + 0 = x (input) + 1 = mean (input) + 2 = inv_variance (input) + 3 = scale (input) + 4 = bias (input) + 5 = epsilon (runtime scalar — no value_type/value fields) + 6 = y (output) + """ + channel_dims = [1, x_dims[1]] + [1] * (len(x_dims) - 2) + channel_strides = compute_contiguous_strides(channel_dims) + x_strides = compute_contiguous_strides(x_dims) + + tensors = [ + { + "uid": 0, + "name": "x", + "dims": x_dims, + "strides": x_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 1, + "name": "mean", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 2, + "name": "variance", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 3, + "name": "scale", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 4, + "name": "bias", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 5, + "name": "epsilon", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + # Intentionally no "value_type"/"value" — runtime form. + # The frontend will reject this via validateScalarParameter. + }, + { + "uid": 6, + "name": "y", + "dims": x_dims, + "strides": x_strides, + "data_type": "float", + "virtual": False, + }, + ] + + return { + "nodes": [ + { + "type": "BatchnormInferenceAttributesVarianceExt", + "compute_data_type": "float", + "name": "", + "inputs": { + "x_tensor_uid": 0, + "mean_tensor_uid": 1, + "variance_tensor_uid": 2, + "scale_tensor_uid": 3, + "bias_tensor_uid": 4, + "epsilon_tensor_uid": 5, + }, + "outputs": { + "y_tensor_uid": 6, + }, + } + ], + "tensors": tensors, + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "", + } + + +def execute_batchnorm_inference_variance_ext(x, mean, variance, scale, bias, epsilon): + """BN inference (variance_ext form) reference computation. + + Computes y = scale * (x - mean) / sqrt(variance + epsilon) + bias. + This matches what the provider kernel does when it receives variance + epsilon + and computes inv_variance internally. + """ + x_f = x.float() + inv_var = 1.0 / torch.sqrt(variance.float() + float(epsilon)) + y = scale.float() * (x_f - mean.float()) * inv_var + bias.float() + return y.to(x.dtype) + + +def generate_epsilon_bundle(base_filename, x_dims, scalar_value, seed): + """Generate the epsilon negative-test bundle. + + Writes graph JSON + golden .bin files + meta. The graph uses a runtime + epsilon (no value_type/value in JSON), so validate() returns INVALID_VALUE + and a correct provider never executes. Golden outputs are computed with + the correct epsilon (1e-5), so if a broken provider bypasses validation + and executes with epsilon=scalar_value instead, its output diverges. + """ + os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) + + print( + f"Generating BN epsilon runtime scalar bundle (NEGATIVE TEST): {base_filename}" + ) + print(f" x_dims: {x_dims}, epsilon uid=5, detection value={scalar_value}") + print( + f" Golden computed with correct epsilon=1e-5; broken provider using " + f"epsilon={scalar_value} produces detectably wrong output." + ) + + C = x_dims[1] + channel_dims = [1, C] + [1] * (len(x_dims) - 2) + + rng = torch.Generator().manual_seed(seed) + x = torch.empty(x_dims, dtype=torch.float32).uniform_(-1.0, 1.0, generator=rng) + mean = torch.empty(channel_dims, dtype=torch.float32).uniform_( + -0.5, 0.5, generator=rng + ) + # variance must be non-negative + variance = torch.empty(channel_dims, dtype=torch.float32).uniform_( + 0.1, 2.0, generator=rng + ) + scale = torch.empty(channel_dims, dtype=torch.float32).uniform_( + 0.5, 2.0, generator=rng + ) + bias = torch.empty(channel_dims, dtype=torch.float32).uniform_( + -0.5, 0.5, generator=rng + ) + # epsilon runtime tensor: detection value, but golden computed with correct 1e-5 + epsilon_tensor = torch.full([1], scalar_value, dtype=torch.float32) + correct_epsilon = 1e-5 + + y = execute_batchnorm_inference_variance_ext( + x, mean, variance, scale, bias, correct_epsilon + ) + + graph_json = build_epsilon_graph_json(x_dims) + json_path = f"{base_filename}.json" + with open(json_path, "w") as f: + json.dump(graph_json, f, indent=4) + f.write("\n") + print(f" Graph JSON: {json_path}") + + # Write .bin files: uid order matches tensor UIDs in graph JSON + # uid 0=x, 1=mean, 2=variance, 3=scale, 4=bias, 5=epsilon, 6=y + tensor_data = [ + ("x", x, 0), + ("mean", mean, 1), + ("variance", variance, 2), + ("scale", scale, 3), + ("bias", bias, 4), + ("epsilon", epsilon_tensor, 5), + ("y", y, 6), + ] + for name, tensor, uid in tensor_data: + bin_path = f"{base_filename}.tensor{uid}.bin" + save_tensor_bin(tensor, bin_path) + print(f" tensor{uid} ({name}): {bin_path} ({os.path.getsize(bin_path)} bytes)") + + meta = { + "format_version": 1, + "operation": "BatchnormFwdInferenceRuntimeScalar/Epsilon", + "generator": "generate_batchnorm_runtime_scalar_golden.py", + "generator_sha256": _get_generator_sha256(), + "generator_version": GENERATOR_VERSION, + "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%dT%H:%M:%SZ" + ), + "reference_source": f"PyTorch {torch.__version__}", + "reference_strategy": "pytorch_bn_inference_variance_ext", + "rocm_version": "", + "seed": seed, + "notes": ( + "NEGATIVE TEST: epsilon (uid=5) is a runtime tensor (no value_type/value fields). " + "hipDNN's validateScalarParameter requires epsilon to be pass_by_value==true, so " + f"validate() must return INVALID_VALUE. Golden output is computed with correct " + f"epsilon=1e-5. Detection value={scalar_value} is intentionally far from 1e-5: " + "a broken provider that bypasses validation and executes with the wrong epsilon " + "will produce output that diverges from the golden data." + ), + "config": { + "scalar": "epsilon", + "x_dims": x_dims, + "scalar_uid": 5, + "scalar_value": scalar_value, + "correct_epsilon": 1e-5, + "expected_failure": "validate", + }, + } + meta_path = f"{base_filename}.meta.json" + with open(meta_path, "w") as f: + json.dump(meta, f, indent=4) + f.write("\n") + print(f" Meta JSON: {meta_path}") + + +# --------------------------------------------------------------------------- +# Momentum bundle (positive test — golden output generated) +# --------------------------------------------------------------------------- + + +def execute_batchnorm_fwd_training( + x, scale, bias, prev_running_mean, prev_running_var, momentum +): + """BN forward training reference via PyTorch batch_norm (training=True). + + Returns (y, mean_out, inv_var_out, next_running_mean, next_running_var). + mean_out and inv_var_out are derived from the same population statistics + that PyTorch's batch_norm kernel uses internally, ensuring they match + provider output. + """ + C = x.shape[1] + reduce_dims = [d for d in range(x.ndim) if d != 1] + shape = prev_running_mean.shape + + # Compute batch statistics (population, matching PyTorch's internal kernel) + x_f = x.float() + mean_out = x_f.mean(dim=reduce_dims, keepdim=True) + var_batch = x_f.var(dim=reduce_dims, unbiased=False, keepdim=True) + inv_var_out = 1.0 / torch.sqrt(var_batch + 1e-5) + + # PyTorch batch_norm expects 1-D running stats + rm = prev_running_mean.view(C).clone().float() + rv = prev_running_var.view(C).clone().float() + s = scale.view(C).float() + b = bias.view(C).float() + + y = F.batch_norm( + x_f, + rm, + rv, + weight=s, + bias=b, + training=True, + momentum=float(momentum), + eps=1e-5, + ) + + # After batch_norm(training=True), rm and rv are updated in-place by PyTorch + next_running_mean = rm.view(shape) + next_running_var = rv.view(shape) + + return ( + y.to(x.dtype), + mean_out.view(shape), + inv_var_out.view(shape), + next_running_mean, + next_running_var, + ) + + +def build_momentum_graph_json(x_dims, momentum_value): + """BN forward training with momentum as a runtime tensor. + + Tensor UIDs: + 0 = x (input) + 1 = scale (input) + 2 = bias (input) + 3 = epsilon (compile-time scalar, value=1e-5) + 4 = prev_running_mean (input) + 5 = prev_running_var (input) + 6 = momentum (runtime scalar — no value_type/value fields) + 7 = y (output) + 8 = mean_out (output) + 9 = inv_var_out (output) + 10 = next_running_mean (output) + 11 = next_running_var (output) + """ + x_strides = compute_contiguous_strides(x_dims) + channel_dims = [1, x_dims[1]] + [1] * (len(x_dims) - 2) + channel_strides = compute_contiguous_strides(channel_dims) + + tensors = [ + { + "uid": 0, + "name": "x", + "dims": x_dims, + "strides": x_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 1, + "name": "scale", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 2, + "name": "bias", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + # epsilon stays compile-time — only momentum is runtime in this bundle + { + "uid": 3, + "name": "epsilon", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + "value_type": "Float32Value", + "value": 1e-5, + }, + { + "uid": 4, + "name": "prev_running_mean", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 5, + "name": "prev_running_var", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 6, + "name": "momentum", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + # Intentionally no "value_type"/"value" — runtime form. + }, + { + "uid": 7, + "name": "y", + "dims": x_dims, + "strides": x_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 8, + "name": "mean_out", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 9, + "name": "inv_var_out", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 10, + "name": "next_running_mean", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + { + "uid": 11, + "name": "next_running_var", + "dims": channel_dims, + "strides": channel_strides, + "data_type": "float", + "virtual": False, + }, + ] + + return { + "nodes": [ + { + "type": "BatchnormAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "x_tensor_uid": 0, + "scale_tensor_uid": 1, + "bias_tensor_uid": 2, + "epsilon_tensor_uid": 3, + "peer_stats_tensor_uid": [], + "prev_running_mean_tensor_uid": 4, + "prev_running_variance_tensor_uid": 5, + "momentum_tensor_uid": 6, + }, + "outputs": { + "y_tensor_uid": 7, + "mean_tensor_uid": 8, + "inv_variance_tensor_uid": 9, + "next_running_mean_tensor_uid": 10, + "next_running_variance_tensor_uid": 11, + }, + } + ], + "tensors": tensors, + "io_data_type": "float", + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "", + } + + +def generate_momentum_bundle( + base_filename, x_dims, scalar_value, seed, min_val, max_val +): + """Generate the momentum positive-test bundle (graph JSON + .bin + meta).""" + os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) + + print(f"Generating BN momentum runtime scalar bundle: {base_filename}") + print(f" x_dims: {x_dims}, momentum uid=6, detection value={scalar_value}") + print(f" seed: {seed}, input range: [{min_val}, {max_val}]") + + rng = torch.Generator().manual_seed(seed) + C = x_dims[1] + channel_dims = [1, C] + [1] * (len(x_dims) - 2) + + x = torch.empty(x_dims, dtype=torch.float32).uniform_( + min_val, max_val, generator=rng + ) + scale = torch.empty(channel_dims, dtype=torch.float32).uniform_( + 0.5, 2.0, generator=rng + ) + bias = torch.empty(channel_dims, dtype=torch.float32).uniform_( + -0.5, 0.5, generator=rng + ) + prev_running_mean = torch.empty(channel_dims, dtype=torch.float32).uniform_( + -1.0, 1.0, generator=rng + ) + prev_running_var = torch.empty(channel_dims, dtype=torch.float32).uniform_( + 0.1, 2.0, generator=rng + ) + momentum_tensor = torch.full([1], scalar_value, dtype=torch.float32) + + y, mean_out, inv_var_out, next_running_mean, next_running_var = ( + execute_batchnorm_fwd_training( + x, scale, bias, prev_running_mean, prev_running_var, scalar_value + ) + ) + + assert not torch.isnan(y).any(), "NaN in y" + assert not torch.isinf(y).any(), "Inf in y" + + # Write tensor .bin files + tensor_data = [ + ("x", x, 0), + ("scale", scale, 1), + ("bias", bias, 2), + # uid=3 is epsilon (compile-time, baked in JSON — still write bin for input) + ("epsilon", torch.tensor([1e-5]), 3), + ("prev_running_mean", prev_running_mean, 4), + ("prev_running_var", prev_running_var, 5), + ("momentum", momentum_tensor, 6), + ("y", y, 7), + ("mean_out", mean_out, 8), + ("inv_var_out", inv_var_out, 9), + ("next_running_mean", next_running_mean, 10), + ("next_running_var", next_running_var, 11), + ] + for name, tensor, uid in tensor_data: + bin_path = f"{base_filename}.tensor{uid}.bin" + save_tensor_bin(tensor, bin_path) + size_bytes = os.path.getsize(bin_path) + print(f" {name} (uid={uid}): {list(tensor.shape)} -> {size_bytes} bytes") + + graph_json = build_momentum_graph_json(x_dims, scalar_value) + json_path = f"{base_filename}.json" + with open(json_path, "w") as f: + json.dump(graph_json, f, indent=4) + f.write("\n") + print(f" Graph JSON: {json_path}") + + rocm_ver = "" + if "+rocm" in torch.__version__: + rocm_ver = torch.__version__.split("+rocm")[1] + + meta = { + "format_version": 1, + "operation": "BatchnormFwdTrainingRuntimeScalar/Momentum", + "generator": "generate_batchnorm_runtime_scalar_golden.py", + "generator_sha256": _get_generator_sha256(), + "generator_version": GENERATOR_VERSION, + "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%dT%H:%M:%SZ" + ), + "reference_source": f"PyTorch {torch.__version__}", + "reference_strategy": "pytorch_batch_norm_training", + "rocm_version": rocm_ver, + "seed": seed, + "notes": ( + "Runtime scalar bundle: momentum (uid=6) is a runtime tensor (no value_type/value " + f"field in JSON). Detection value={scalar_value} is intentionally far from the " + "compile-time default (0.5) to expose providers that ignore the runtime momentum." + ), + "config": { + "scalar": "momentum", + "x_dims": x_dims, + "scalar_uid": 6, + "scalar_value": scalar_value, + }, + } + meta_path = f"{base_filename}.meta.json" + with open(meta_path, "w") as f: + json.dump(meta, f, indent=4) + f.write("\n") + print(f" Meta JSON: {meta_path}") + + +# --------------------------------------------------------------------------- +# Entry point +# --------------------------------------------------------------------------- + + +def main(): + parser = argparse.ArgumentParser( + description=( + "Generate batchnorm runtime scalar golden reference bundles. " + "For epsilon: generates a negative-test bundle (graph JSON only, no golden). " + "For momentum: generates a positive-test bundle with full golden output." + ) + ) + parser.add_argument( + "--base-filename", + required=True, + help="Path prefix for output files (no extension)", + ) + parser.add_argument( + "--scalar", + required=True, + choices=["epsilon", "momentum"], + help="Which scalar to make runtime: 'epsilon' (negative test) or 'momentum' (positive test)", + ) + parser.add_argument( + "--scalar-value", + type=float, + required=True, + help=( + "Detection value for the runtime scalar tensor. " + "Use a value far from the compile-time default: " + "epsilon default=1e-5 (use ~1.0), momentum default=0.5 (use ~0.9)." + ), + ) + parser.add_argument( + "--size", + nargs="+", + type=int, + required=True, + help="Dimensions of the x tensor (e.g. --size 2 3 4 5)", + ) + parser.add_argument("--seed", type=int, default=42) + parser.add_argument("--min", type=float, default=0.1, dest="min_val") + parser.add_argument("--max", type=float, default=1.0, dest="max_val") + args = parser.parse_args() + + if args.scalar == "epsilon": + generate_epsilon_bundle( + base_filename=args.base_filename, + x_dims=args.size, + scalar_value=args.scalar_value, + seed=args.seed, + ) + else: + generate_momentum_bundle( + base_filename=args.base_filename, + x_dims=args.size, + scalar_value=args.scalar_value, + seed=args.seed, + min_val=args.min_val, + max_val=args.max_val, + ) + + print("\nDone.") + + +if __name__ == "__main__": + main() diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py new file mode 100644 index 000000000000..49ca0b686d5e --- /dev/null +++ b/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python3 +# Copyright © Advanced Micro Devices, Inc., or its affiliates. +# SPDX-License-Identifier: MIT +""" +Pointwise Runtime Scalar Golden Reference Bundle Generator + +Generates pre-computed reference data for pointwise operations where one +operand is a runtime pass-by-value scalar tensor (dims=[1], strides=[1]), +rather than a compile-time baked scalar. + +Supported operations: + add — out = in0 + scalar + mul — out = in0 * scalar + +Output: {base_filename}.json + {base_filename}.tensor{uid}.bin + {base_filename}.meta.json + +Usage: + python generate_pointwise_runtime_scalar_golden.py \\ + --base-filename bundles/PointwiseFwdRuntimeScalar/Add/Small/Small \\ + --operation add --dims 2 4 6 8 --scalar-value 100.0 --dtype float --seed 42 + + python generate_pointwise_runtime_scalar_golden.py \\ + --base-filename bundles/PointwiseFwdRuntimeScalar/Mul/Small/Small \\ + --operation mul --dims 2 4 6 8 --scalar-value 10.0 --dtype float --seed 42 +""" + +import argparse +import datetime +import hashlib +import json +import os +import sys + +import torch + +# Bump when generator logic changes in a way that affects output data. +# 1.0.0 — Initial: pointwise ADD and MUL with runtime scalar operand (in_1) +GENERATOR_VERSION = "1.0.0" + +DTYPE_MAP = { + "float": {"torch": torch.float32, "json": "float", "bytes": 4}, + "half": {"torch": torch.float16, "json": "half", "bytes": 2}, + "bfloat16": {"torch": torch.bfloat16, "json": "bfloat16", "bytes": 2}, +} + +OPERATION_MAP = { + "add": "add", + "mul": "mul", +} + + +def compute_contiguous_strides(dims): + strides = [] + stride = 1 + for d in reversed(dims): + strides.append(stride) + stride *= d + strides.reverse() + return strides + + +def execute_pointwise(in0, scalar_val, operation, compute_dtype): + in0_f = in0.to(compute_dtype) + scalar = torch.full([1], scalar_val, dtype=compute_dtype) + if operation == "add": + out = in0_f + scalar + elif operation == "mul": + out = in0_f * scalar + else: + raise ValueError(f"Unsupported operation: {operation}") + return out.to(in0.dtype), scalar + + +def save_tensor_bin(tensor, path): + t = tensor.contiguous().cpu() + if t.dtype in (torch.bfloat16, torch.float16): + raw = t.view(torch.uint8).numpy().tobytes() + else: + raw = t.numpy().tobytes() + with open(path, "wb") as f: + f.write(raw) + + +def build_graph_json(dims, strides, scalar_val, operation, dtype_str): + # UIDs: + # 0 = in0 (main input tensor) + # 1 = in1 (runtime scalar, dims=[1], strides=[1]) + # 2 = out0 (output tensor) + tensors = [ + { + "uid": 0, + "name": "in0", + "dims": dims, + "strides": strides, + "data_type": dtype_str, + "virtual": False, + }, + { + "uid": 1, + "name": "scalar", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + # No "value_type" / "value" fields — this is the runtime form + }, + { + "uid": 2, + "name": "out0", + "dims": dims, + "strides": strides, + "data_type": dtype_str, + "virtual": False, + }, + ] + + graph = { + "nodes": [ + { + "type": "PointwiseAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "operation": OPERATION_MAP[operation], + "in_0_tensor_uid": 0, + "in_1_tensor_uid": 1, + "in_2_tensor_uid": None, + "axis_tensor_uid": None, + "relu_lower_clip": None, + "relu_upper_clip": None, + "relu_lower_clip_slope": None, + "swish_beta": None, + "elu_alpha": None, + "softplus_beta": None, + }, + "outputs": { + "out_0_tensor_uid": 2, + }, + } + ], + "tensors": tensors, + "io_data_type": dtype_str, + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "", + } + return graph + + +def _get_generator_sha256(): + script_path = os.path.abspath(__file__) + with open(script_path, "rb") as f: + return hashlib.sha256(f.read()).hexdigest() + + +def build_meta_json(config, pytorch_version): + rocm_ver = "" + if "+rocm" in pytorch_version: + rocm_ver = pytorch_version.split("+rocm")[1] + + return { + "format_version": 1, + "operation": f"PointwiseFwdRuntimeScalar/{config['operation'].upper()}", + "generator": "generate_pointwise_runtime_scalar_golden.py", + "generator_sha256": _get_generator_sha256(), + "generator_version": GENERATOR_VERSION, + "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%dT%H:%M:%SZ" + ), + "reference_source": f"PyTorch {pytorch_version}", + "reference_strategy": "pytorch_elementwise", + "rocm_version": rocm_ver, + "seed": config["seed"], + "notes": ( + f"Runtime scalar bundle: in_1 (uid=1) is a runtime pass-by-value tensor " + f"(no value_type/value fields in JSON). Detection value={config['scalar_value']} is " + f"intentionally far from any compile-time default to expose providers that " + f"ignore the runtime scalar." + ), + "config": { + "operation": config["operation"], + "dims": config["dims"], + "dtype": config["dtype"], + "scalar_uid": 1, + "scalar_value": config["scalar_value"], + }, + } + + +def generate_bundle( + base_filename, + operation, + dims, + dtype="float", + scalar_value=100.0, + seed=42, + min_val=0.1, + max_val=1.0, +): + if dtype not in DTYPE_MAP: + print( + f"ERROR: --dtype must be one of {list(DTYPE_MAP.keys())} (got '{dtype}')", + file=sys.stderr, + ) + sys.exit(1) + if operation not in OPERATION_MAP: + print( + f"ERROR: --operation must be one of {list(OPERATION_MAP.keys())} (got '{operation}')", + file=sys.stderr, + ) + sys.exit(1) + + dtype_info = DTYPE_MAP[dtype] + torch_dtype = dtype_info["torch"] + strides = compute_contiguous_strides(dims) + + os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) + + print(f"Generating pointwise runtime scalar bundle: {base_filename}") + print(f" operation: {operation}") + print(f" dims: {dims}, strides: {strides}, dtype: {dtype}") + print(f" scalar uid=1, value={scalar_value} (runtime — no value field in JSON)") + print(f" seed: {seed}, input range: [{min_val}, {max_val}]") + + rng = torch.Generator().manual_seed(seed) + in0 = torch.empty(dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) + + out0, scalar_tensor = execute_pointwise(in0, scalar_value, operation, torch.float32) + + assert not torch.isnan(out0).any(), "NaN in output" + assert not torch.isinf(out0).any(), "Inf in output" + + # Write tensor .bin files + for name, tensor, uid in [ + ("in0", in0, 0), + ("scalar", scalar_tensor, 1), + ("out0", out0, 2), + ]: + bin_path = f"{base_filename}.tensor{uid}.bin" + save_tensor_bin(tensor, bin_path) + size_bytes = os.path.getsize(bin_path) + print( + f" {name} (uid={uid}): {list(tensor.shape)} {tensor.dtype} -> {size_bytes} bytes" + ) + + # Write graph JSON + graph_json = build_graph_json( + dims, strides, scalar_value, operation, dtype_info["json"] + ) + json_path = f"{base_filename}.json" + with open(json_path, "w") as f: + json.dump(graph_json, f, indent=4) + f.write("\n") + print(f" Graph JSON: {json_path}") + + # Write meta JSON + config = { + "operation": operation, + "dims": dims, + "dtype": dtype, + "scalar_value": scalar_value, + "seed": seed, + } + meta_json = build_meta_json(config, torch.__version__) + meta_path = f"{base_filename}.meta.json" + with open(meta_path, "w") as f: + json.dump(meta_json, f, indent=4) + f.write("\n") + print(f" Meta JSON: {meta_path}") + + +def main(): + parser = argparse.ArgumentParser( + description="Generate pointwise runtime scalar golden reference bundles" + ) + parser.add_argument( + "--base-filename", + required=True, + help="Path prefix for output files (no extension)", + ) + parser.add_argument( + "--operation", + required=True, + choices=list(OPERATION_MAP.keys()), + help="Pointwise operation: add or mul", + ) + parser.add_argument( + "--dims", + nargs="+", + type=int, + required=True, + help="Dimensions of in0 tensor (e.g. --dims 2 4 6 8)", + ) + parser.add_argument( + "--scalar-value", + type=float, + required=True, + help=( + "Value for the runtime scalar tensor (uid=1). " + "Use a value far from any compile-time default to enable detection " + "(e.g. 100.0 for ADD, 10.0 for MUL)." + ), + ) + parser.add_argument( + "--dtype", + default="float", + choices=list(DTYPE_MAP.keys()), + help="Data type for in0 and out0 tensors (default: float)", + ) + parser.add_argument("--seed", type=int, default=42) + parser.add_argument("--min", type=float, default=0.1, dest="min_val") + parser.add_argument("--max", type=float, default=1.0, dest="max_val") + args = parser.parse_args() + + generate_bundle( + base_filename=args.base_filename, + operation=args.operation, + dims=args.dims, + dtype=args.dtype, + scalar_value=args.scalar_value, + seed=args.seed, + min_val=args.min_val, + max_val=args.max_val, + ) + print("\nDone.") + + +if __name__ == "__main__": + main() diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py new file mode 100644 index 000000000000..57277acbf099 --- /dev/null +++ b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py @@ -0,0 +1,418 @@ +#!/usr/bin/env python3 +# Copyright © Advanced Micro Devices, Inc., or its affiliates. +# SPDX-License-Identifier: MIT +""" +SDPA Forward Runtime Scale Golden Reference Bundle Generator + +Generates pre-computed reference data for SDPA forward where the attention +scale is provided as a runtime pass-by-value tensor (dims=[1], strides=[1], +uid=4) rather than a compile-time baked scalar (attn_scale_value attribute). + +In existing SDPA bundles the scale is baked into the node's `attn_scale_value` +attribute. This script instead wires it as a runtime tensor via `scale_tensor_uid`, +leaving `attn_scale_value` as null. A provider that ignores the runtime scale +and falls back to a compile-time default will produce detectably wrong output. + +Uses PyTorch's SDPBackend.MATH as the golden reference source. +Supports BF16 and FP16 data types. + +Output: {base_filename}.json + {base_filename}.tensor{uid}.bin + {base_filename}.meta.json + +Usage: + python generate_sdpa_runtime_scale_golden.py \\ + --base-filename bundles/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small \\ + --q-dims 2 4 256 128 --v-dims 2 4 256 128 \\ + --scale-value 1.0 --dtype bf16 --seed 42 +""" + +import argparse +import datetime +import hashlib +import json +import math +import os +import sys + +import torch +import torch.nn.functional as F +from torch.nn.attention import SDPBackend, sdpa_kernel + +# Bump when generator logic changes in a way that affects output data. +# 1.0.0 — Initial: SDPA forward with runtime scale tensor (uid=4) +GENERATOR_VERSION = "1.0.0" + +DTYPE_MAP = { + "bf16": {"torch": torch.bfloat16, "json": "bfloat16", "bytes": 2}, + "fp16": {"torch": torch.float16, "json": "half", "bytes": 2}, +} + +# UID assignments +UID_Q = 0 +UID_K = 1 +UID_V = 2 +UID_O = 3 +UID_SCALE = 4 # runtime scalar tensor — dims=[1], strides=[1] + + +def compute_contiguous_strides(dims): + strides = [] + stride = 1 + for d in reversed(dims): + strides.append(stride) + stride *= d + strides.reverse() + return strides + + +def compute_forward(Q, K, V, scale, H_q, H_kv): + """SDPA forward via PyTorch Math backend.""" + with sdpa_kernel(SDPBackend.MATH): + O = F.scaled_dot_product_attention( + Q, + K, + V, + scale=scale, + enable_gqa=(H_q != H_kv), + ) + return O + + +def save_tensor_bin(tensor, path): + t = tensor.contiguous().cpu() + if t.dtype in (torch.bfloat16, torch.float16): + raw = t.view(torch.uint8).numpy().tobytes() + else: + raw = t.numpy().tobytes() + with open(path, "wb") as f: + f.write(raw) + + +def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): + """Build the SDPA graph JSON with scale wired as a runtime tensor. + + Key difference from the compile-time variant (generate_sdpa_fwd_golden.py): + - scale_tensor_uid = UID_SCALE (runtime-with-default PBV tensor) + - scale tensor carries value_type/value=2.0 as a wrong compile-time bake-in + - attn_scale_value = null (forces CPU reference to read from variantPack) + A provider that ignores the runtime tensor and reads the bake-in (2.0) or falls + back to 1/sqrt(headDim) produces output that diverges from the CPU reference. + """ + tensors = [ + { + "uid": UID_Q, + "name": "Q", + "dims": q_dims, + "strides": compute_contiguous_strides(q_dims), + "data_type": dtype_str, + "virtual": False, + }, + { + "uid": UID_K, + "name": "K", + "dims": k_dims, + "strides": compute_contiguous_strides(k_dims), + "data_type": dtype_str, + "virtual": False, + }, + { + "uid": UID_V, + "name": "V", + "dims": v_dims, + "strides": compute_contiguous_strides(v_dims), + "data_type": dtype_str, + "virtual": False, + }, + { + "uid": UID_O, + "name": "O", + "dims": o_dims, + "strides": compute_contiguous_strides(o_dims), + "data_type": dtype_str, + "virtual": False, + }, + { + "uid": UID_SCALE, + "name": "scale", + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + "is_runtime_pass_by_value": True, + "value_type": "Float32Value", + # Compile-time bake-in: intentionally wrong so a provider that ignores the + # runtime tensor and reads this value instead produces detectably wrong output. + "value": 2.0, + }, + ] + + graph = { + "nodes": [ + { + "type": "SdpaAttributes", + "compute_data_type": "float", + "name": "", + "inputs": { + "q_tensor_uid": UID_Q, + "k_tensor_uid": UID_K, + "v_tensor_uid": UID_V, + "attn_mask_tensor_uid": None, + "scale_tensor_uid": UID_SCALE, # runtime tensor + "seq_len_q_tensor_uid": None, + "seq_len_kv_tensor_uid": None, + "seed_tensor_uid": None, + "offset_tensor_uid": None, + "dropout_mask_tensor_uid": None, + "dropout_scale_tensor_uid": None, + "page_table_k_tensor_uid": None, + "page_table_v_tensor_uid": None, + "block_mask_tensor_uid": None, + "sink_token_tensor_uid": None, + "descale_q_tensor_uid": None, + "descale_k_tensor_uid": None, + "descale_v_tensor_uid": None, + "descale_s_tensor_uid": None, + "scale_s_tensor_uid": None, + "scale_o_tensor_uid": None, + }, + "outputs": { + "o_tensor_uid": UID_O, + "stats_tensor_uid": None, + "max_tensor_uid": None, + "sum_exp_tensor_uid": None, + "rng_dump_tensor_uid": None, + "amax_s_tensor_uid": None, + "amax_o_tensor_uid": None, + }, + "attributes": { + "generate_stats": None, + "alibi_mask": False, + "padding_mask": False, + "causal_mask": False, + "causal_mask_bottom_right": False, + "dropout_probability": None, + "attn_scale_value": None, # null — scale is runtime, not baked + "left_bound": None, + "right_bound": None, + "max_seq_len_kv": None, + "diagonal_alignment": "TOP_LEFT", + "mma_core_mode": "float", + "implementation": "AUTO", + }, + } + ], + "tensors": tensors, + "io_data_type": dtype_str, + "compute_data_type": "float", + "intermediate_data_type": "float", + "name": "", + } + return graph + + +def _get_generator_sha256(): + script_path = os.path.abspath(__file__) + with open(script_path, "rb") as f: + return hashlib.sha256(f.read()).hexdigest() + + +def build_meta_json(config, pytorch_version): + rocm_ver = "" + if "+rocm" in pytorch_version: + rocm_ver = pytorch_version.split("+rocm")[1] + + return { + "format_version": 1, + "operation": "SdpaFwdRuntimeScale", + "generator": "generate_sdpa_runtime_scale_golden.py", + "generator_sha256": _get_generator_sha256(), + "generator_version": GENERATOR_VERSION, + "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%dT%H:%M:%SZ" + ), + "reference_source": f"PyTorch {pytorch_version}", + "reference_backend": "pytorch_math_backend", + "rocm_version": rocm_ver, + "seed": config["seed"], + "notes": ( + f"Runtime scale bundle: scale (uid={UID_SCALE}) is a runtime tensor " + "(no value_type/value field in JSON; attn_scale_value attribute is null). " + f"Detection value={config['scale_value']} is intentionally far from the " + "compile-time default (1/sqrt(D_qk)) to expose providers that use a " + "baked-in compile-time scale instead of the runtime tensor." + ), + "config": { + "q_dims": config["q_dims"], + "v_dims": config["v_dims"], + "dtype": config["dtype"], + "scale_uid": UID_SCALE, + "scale_value": config["scale_value"], + "gqa_ratio": config["q_dims"][1] // config["v_dims"][1], + }, + } + + +def generate_bundle( + base_filename, + q_dims, + v_dims, + dtype="bf16", + scale_value=1.0, + seed=42, + min_val=-1.0, + max_val=1.0, +): + if dtype not in DTYPE_MAP: + print( + f"ERROR: --dtype must be one of {list(DTYPE_MAP.keys())} (got '{dtype}')", + file=sys.stderr, + ) + sys.exit(1) + + B, H_q, S_q, D_qk = q_dims + B_v, H_kv, S_kv, D_v = v_dims + k_dims = [B, H_kv, S_kv, D_qk] + o_dims = [B, H_q, S_q, D_v] + + errors = [] + if B_v != B: + errors.append(f"Batch mismatch: Q batch={B}, V batch={B_v}") + if H_q % H_kv != 0: + errors.append(f"H_q ({H_q}) must be divisible by H_kv ({H_kv})") + if min_val >= max_val: + errors.append(f"--min ({min_val}) must be less than --max ({max_val})") + if errors: + for e in errors: + print(f"ERROR: {e}", file=sys.stderr) + sys.exit(1) + + dtype_info = DTYPE_MAP[dtype] + torch_dtype = dtype_info["torch"] + + os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) + + compile_time_default = 1.0 / math.sqrt(D_qk) + print(f"Generating SDPA runtime scale bundle: {base_filename}") + print(f" Q: {q_dims}, K: {k_dims}, V: {v_dims}, O: {o_dims}") + print(f" dtype: {dtype}, seed: {seed}") + print( + f" scale uid={UID_SCALE}, runtime value={scale_value} " + f"(compile-time default would be {compile_time_default:.6f})" + ) + + rng = torch.Generator().manual_seed(seed) + Q = torch.empty(q_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) + K = torch.empty(k_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) + V = torch.empty(v_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) + scale_tensor = torch.full([1], scale_value, dtype=torch.float32) + + try: + O = compute_forward(Q, K, V, scale_value, H_q, H_kv) + except RuntimeError as e: + print(f"ERROR: PyTorch SDPA failed: {e}", file=sys.stderr) + sys.exit(1) + + for name, t in [("Q", Q), ("K", K), ("V", V), ("O", O)]: + assert not torch.isnan(t).any(), f"NaN in {name}" + assert not torch.isinf(t).any(), f"Inf in {name}" + + # Write tensor .bin files + tensor_list = [ + ("Q", Q, UID_Q), + ("K", K, UID_K), + ("V", V, UID_V), + ("O", O, UID_O), + ("scale", scale_tensor, UID_SCALE), + ] + for name, tensor, uid in tensor_list: + bin_path = f"{base_filename}.tensor{uid}.bin" + save_tensor_bin(tensor, bin_path) + size_bytes = os.path.getsize(bin_path) + print( + f" {name} (uid={uid}): {list(tensor.shape)} {tensor.dtype} -> {size_bytes} bytes" + ) + + # Write graph JSON + graph_json = build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_info["json"]) + json_path = f"{base_filename}.json" + with open(json_path, "w") as f: + json.dump(graph_json, f, indent=4) + f.write("\n") + print(f" Graph JSON: {json_path}") + + # Write meta JSON + config = { + "q_dims": q_dims, + "v_dims": v_dims, + "dtype": dtype, + "scale_value": scale_value, + "seed": seed, + } + meta_json = build_meta_json(config, torch.__version__) + meta_path = f"{base_filename}.meta.json" + with open(meta_path, "w") as f: + json.dump(meta_json, f, indent=4) + f.write("\n") + print(f" Meta JSON: {meta_path}") + + +def main(): + parser = argparse.ArgumentParser( + description="Generate SDPA forward runtime scale golden reference bundles" + ) + parser.add_argument( + "--base-filename", + required=True, + help="Path prefix for output files (no extension)", + ) + parser.add_argument( + "--q-dims", + nargs=4, + type=int, + required=True, + metavar=("B", "H_Q", "S_Q", "D_QK"), + help="Query tensor dims: batch, heads_q, seq_q, head_dim_qk", + ) + parser.add_argument( + "--v-dims", + nargs=4, + type=int, + required=True, + metavar=("B", "H_KV", "S_KV", "D_V"), + help="Value tensor dims: batch, heads_kv, seq_kv, head_dim_v", + ) + parser.add_argument( + "--dtype", + default="bf16", + choices=list(DTYPE_MAP.keys()), + help="Input/output tensor dtype (default: bf16)", + ) + parser.add_argument( + "--scale-value", + type=float, + default=1.0, + help=( + "Detection value for the runtime scale tensor (uid=4). " + "Default=1.0 (no scaling) is far from the typical compile-time " + "default of 1/sqrt(D_qk) to enable detection of incorrect handling." + ), + ) + parser.add_argument("--seed", type=int, default=42) + parser.add_argument("--min", type=float, default=-1.0, dest="min_val") + parser.add_argument("--max", type=float, default=1.0, dest="max_val") + args = parser.parse_args() + + generate_bundle( + base_filename=args.base_filename, + q_dims=args.q_dims, + v_dims=args.v_dims, + dtype=args.dtype, + scale_value=args.scale_value, + seed=args.seed, + min_val=args.min_val, + max_val=args.max_val, + ) + print("\nDone.") + + +if __name__ == "__main__": + main() diff --git a/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp b/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp index 1f0c07b14127..fb6ec11011f2 100644 --- a/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp +++ b/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp @@ -44,6 +44,7 @@ TEST(TestSdpaFwdPlan, ExecutePlan) *tensorMap.at(nodeAttributes->v_tensor_uid()), *tensorMap.at(nodeAttributes->o_tensor_uid()), std::nullopt, + std::nullopt, /*leftBound=*/-1, /*rightBound=*/-1, /*topLeftAlignment=*/true); @@ -141,6 +142,7 @@ TEST(TestSdpaFwdPlan, ExecutePlanWithCausalMask) *tensorMap.at(nodeAttributes->v_tensor_uid()), *tensorMap.at(nodeAttributes->o_tensor_uid()), std::nullopt, + std::nullopt, /*leftBound=*/-1, /*rightBound=*/0, /*topLeftAlignment=*/true); From 83068713e9d00ef376f217338e569b5332062021 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Mon, 27 Jul 2026 14:02:03 -0600 Subject: [PATCH 3/9] fix(hipdnn): reject runtime pass-by-value tensors with baked fallback values Template-sweep tensor patches can flip a tensor's is_runtime_pass_by_value flag to true while still leaving its original value_type/value from the template. When that happens, the CPU reference and the provider both silently short-circuit to the baked value, and the runtime injection path is never exercised even though the test appears to cover it. applyTensorPatches now checks this invariant after all patches are applied and throws if a tensor carries is_runtime_pass_by_value=true alongside a value_type or value. The existing bundle-loading error handling converts this into an INVALID_SWEEP_CASE, so a misconfigured case is excluded from test discovery and logged rather than passing without actually testing runtime injection. Runtime scalar coverage for Batchnorm and RMSNorm is consolidated into the existing template-sweep bundles as additional cases rather than standalone bundles, removing the now-redundant BatchnormFwdInferenceRuntimeScalar, BatchnormFwdTrainingRuntimeScalar, and PointwiseFwdRuntimeScalar bundles along with their golden data generator scripts. The SDPA runtime-scale golden data is updated to match, and its generator script is renamed to generate_sdpa_runtime_scale_test_bundle.py to reflect what it produces. The reference data generation scripts gain a requirements.txt pinning their torch dependency. ALMIOPEN-2267 --- .../quick/Batchnorm/Default/sweep.json | 209 ++++++ .../quick/Batchnorm/Variant2/sweep.json | 129 ++++ .../Epsilon/Small/Small.json | 146 ---- .../Epsilon/Small/Small.meta.json | 26 - .../Small/Small.json | 241 ------ .../Small/Small.meta.json | 16 - .../Default/sweep.json | 129 ++++ .../Default/sweep.json | 143 ++++ .../BatchnormPointwise/Default/sweep.json | 143 ++++ .../BatchnormPointwise/Variant2/sweep.json | 223 ++++++ .../Add/Small/Small.json | 58 -- .../Add/Small/Small.meta.json | 16 - .../Mul/Small/Small.json | 58 -- .../Mul/Small/Small.meta.json | 16 - .../quick/RMSNorm/Default/sweep.json | 125 ++++ .../quick/RMSNorm/Variant2/sweep.json | 109 +++ .../quick/RMSNorm/Variant3/sweep.json | 93 +++ .../quick/RMSNorm/Variant4/sweep.json | 109 +++ .../bhsd/bf16/Small/Small.json | 72 +- .../bhsd/bf16/Small/Small.meta.json | 17 +- .../bf16/hd128_causal_batch/Small/Small.json | 8 +- .../hd128_causal_batch/Small/Small.meta.json | 7 +- .../bf16/hd128_causal_group/Small/Small.json | 8 +- .../hd128_causal_group/Small/Small.meta.json | 7 +- .../bf16/hd128_nomask_batch/Small/Small.json | 8 +- .../hd128_nomask_batch/Small/Small.meta.json | 7 +- .../SmallStats/SmallStats.json | 8 +- .../SmallStats/SmallStats.meta.json | 7 +- .../bf16/hd128_nomask_group/Small/Small.json | 8 +- .../hd128_nomask_group/Small/Small.meta.json | 7 +- .../bf16/hd192_causal_batch/Small/Small.json | 8 +- .../hd192_causal_batch/Small/Small.meta.json | 7 +- .../bf16/hd192_nomask_batch/Small/Small.json | 8 +- .../hd192_nomask_batch/Small/Small.meta.json | 7 +- .../fp16/hd128_causal_batch/Small/Small.json | 8 +- .../hd128_causal_batch/Small/Small.meta.json | 7 +- .../fp16/hd128_nomask_batch/Small/Small.json | 8 +- .../hd128_nomask_batch/Small/Small.meta.json | 7 +- .../SmallStats/SmallStats.json | 8 +- .../SmallStats/SmallStats.meta.json | 7 +- .../fp16/hd192_causal_batch/Small/Small.json | 8 +- .../hd192_causal_batch/Small/Small.meta.json | 7 +- .../fp16/hd192_nomask_batch/Small/Small.json | 8 +- .../hd192_nomask_batch/Small/Small.meta.json | 7 +- .../fp8/hd128_causal_batch/Small/Small.json | 8 +- .../hd128_causal_batch/Small/Small.meta.json | 7 +- .../fp8/hd128_causal_group/Small/Small.json | 8 +- .../hd128_causal_group/Small/Small.meta.json | 7 +- .../fp8/hd128_nomask_batch/Small/Small.json | 8 +- .../hd128_nomask_batch/Small/Small.meta.json | 7 +- ...enerate_batchnorm_runtime_scalar_golden.py | 691 ------------------ ...enerate_pointwise_runtime_scalar_golden.py | 329 --------- ...enerate_sdpa_runtime_scale_test_bundle.py} | 0 .../reference_data_scripts/requirements.txt | 7 + .../harness/bundle/IntegrationTestBundle.hpp | 81 ++ 55 files changed, 1681 insertions(+), 1730 deletions(-) delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json delete mode 100644 dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py delete mode 100644 dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py rename dnn-providers/integration-tests/reference_data_scripts/{generate_sdpa_runtime_scale_golden.py => generate_sdpa_runtime_scale_test_bundle.py} (100%) create mode 100644 dnn-providers/integration-tests/reference_data_scripts/requirements.txt diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Default/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Default/sweep.json index af42f3614a45..c3069dbb7bb4 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Default/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Default/sweep.json @@ -8244,6 +8244,215 @@ "seed": 42, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdTraining3dFp32.Correctness_5" } + }, + { + "id": "runtime_epsilon_momentum", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 2, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 4, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 5, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 6, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 7, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 8, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 9, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 10, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 11, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 7, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + }, + { + "uid": 8, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormFwdTraining", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=7) promoted to is_runtime_pass_by_value=true, detection value 1.0; momentum (uid=8) promoted to is_runtime_pass_by_value=true, detection value 0.9. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "7": { + "kind": "fixed", + "value": 1.0 + }, + "8": { + "kind": "fixed", + "value": 0.9 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Variant2/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Variant2/sweep.json index 020726bacf99..5fc595457c90 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Variant2/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/Batchnorm/Variant2/sweep.json @@ -5580,6 +5580,135 @@ "seed": 42, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdTraining3dFp32.Correctness_7" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 2, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 3, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 4, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 5, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 6, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 5, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormFwdTraining", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=5) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "5": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json deleted file mode 100644 index 97ac5cfbd455..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "nodes": [ - { - "type": "BatchnormInferenceAttributesVarianceExt", - "compute_data_type": "float", - "name": "", - "inputs": { - "x_tensor_uid": 0, - "mean_tensor_uid": 1, - "variance_tensor_uid": 2, - "scale_tensor_uid": 3, - "bias_tensor_uid": 4, - "epsilon_tensor_uid": 5 - }, - "outputs": { - "y_tensor_uid": 6 - } - } - ], - "tensors": [ - { - "uid": 0, - "name": "x", - "dims": [ - 2, - 3, - 4, - 5 - ], - "strides": [ - 60, - 20, - 5, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 1, - "name": "mean", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 2, - "name": "variance", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 3, - "name": "scale", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 4, - "name": "bias", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 5, - "name": "epsilon", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 6, - "name": "y", - "dims": [ - 2, - 3, - 4, - 5 - ], - "strides": [ - 60, - 20, - 5, - 1 - ], - "data_type": "float", - "virtual": false - } - ], - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "" -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json deleted file mode 100644 index e620083ab219..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small.meta.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "format_version": 1, - "operation": "BatchnormFwdInferenceRuntimeScalar/Epsilon", - "generator": "generate_batchnorm_runtime_scalar_golden.py", - "generator_sha256": "e24401f1082a3b59972afc589bcd538e61eff52adc3fd57f307ab5e7d45c6d0d", - "generator_version": "1.1.0", - "generated_at": "2026-07-17T22:22:44Z", - "reference_source": "PyTorch 2.12.0+rocm7.2", - "reference_strategy": "pytorch_bn_inference_variance_ext", - "rocm_version": "", - "seed": 42, - "notes": "NEGATIVE TEST: epsilon (uid=5) is a runtime tensor (no value_type/value fields). hipDNN's validateScalarParameter requires epsilon to be pass_by_value==true, so validate() must return INVALID_VALUE. Golden output is computed with correct epsilon=1e-5. Detection value=1.0 is intentionally far from 1e-5: a broken provider that bypasses validation and executes with the wrong epsilon will produce output that diverges from the golden data.", - "config": { - "scalar": "epsilon", - "x_dims": [ - 2, - 3, - 4, - 5 - ], - "scalar_uid": 5, - "scalar_value": 1.0, - "correct_epsilon": 1e-05, - "expected_failure": "validate" - } -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json deleted file mode 100644 index 598bc80e293e..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.json +++ /dev/null @@ -1,241 +0,0 @@ -{ - "nodes": [ - { - "type": "BatchnormAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "x_tensor_uid": 0, - "scale_tensor_uid": 1, - "bias_tensor_uid": 2, - "epsilon_tensor_uid": 3, - "peer_stats_tensor_uid": [], - "prev_running_mean_tensor_uid": 4, - "prev_running_variance_tensor_uid": 5, - "momentum_tensor_uid": 6 - }, - "outputs": { - "y_tensor_uid": 7, - "mean_tensor_uid": 8, - "inv_variance_tensor_uid": 9, - "next_running_mean_tensor_uid": 10, - "next_running_variance_tensor_uid": 11 - } - } - ], - "tensors": [ - { - "uid": 0, - "name": "x", - "dims": [ - 2, - 3, - 4, - 5 - ], - "strides": [ - 60, - 20, - 5, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 1, - "name": "scale", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 2, - "name": "bias", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 3, - "name": "epsilon", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false, - "value_type": "Float32Value", - "value": 1e-05 - }, - { - "uid": 4, - "name": "prev_running_mean", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 5, - "name": "prev_running_var", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 6, - "name": "momentum", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 0.5 - }, - { - "uid": 7, - "name": "y", - "dims": [ - 2, - 3, - 4, - 5 - ], - "strides": [ - 60, - 20, - 5, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 8, - "name": "mean_out", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 9, - "name": "inv_var_out", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 10, - "name": "next_running_mean", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - }, - { - "uid": 11, - "name": "next_running_var", - "dims": [ - 1, - 3, - 1, - 1 - ], - "strides": [ - 3, - 1, - 1, - 1 - ], - "data_type": "float", - "virtual": false - } - ], - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "" -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json deleted file mode 100644 index 986d18c5934f..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormFwdTrainingRuntimeScalar/Small/Small.meta.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "format_version": 1, - "operation": "BatchnormFwdTrainingRuntimeScalar/Momentum", - "generator": "generate_batchnorm_runtime_scalar_golden.py", - "generator_sha256": "e24401f1082a3b59972afc589bcd538e61eff52adc3fd57f307ab5e7d45c6d0d", - "generator_version": "1.1.0", - "generated_at": "2026-07-17T22:22:46Z", - "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scalar bundle: momentum (uid=6) has is_runtime_pass_by_value=true with compile-time default value=0.5. Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (0.5) instead of the runtime value produces diverging output.", - "config": { - "scalar": "momentum", - "x_dims": [2, 3, 4, 5], - "scalar_uid": 6, - "compile_time_default": 0.5 - } -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExt/Default/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExt/Default/sweep.json index 265096b5e6e3..7d9b30517e3a 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExt/Default/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExt/Default/sweep.json @@ -10656,6 +10656,135 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdInferenceVariance3dFp32.Correctness_3" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 224 + ], + "strides": [ + 672, + 224, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 224 + ], + "strides": [ + 672, + 224, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 2, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 4, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 5, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 6, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 3, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormFwdInferenceVarianceExt", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalar: epsilon (uid=3) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "3": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExtPointwise/Default/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExtPointwise/Default/sweep.json index 916e32507949..d83f190284d4 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExtPointwise/Default/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormInferenceAttributesVarianceExtPointwise/Default/sweep.json @@ -11784,6 +11784,149 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdInferenceVarianceActiv3dFp32.Correctness_3" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 224 + ], + "strides": [ + 672, + 224, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 224 + ], + "strides": [ + 672, + 224, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 2, + "dims": [ + 1, + 3, + 224 + ], + "strides": [ + 672, + 224, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 3, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 4, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 5, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 6, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 7, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 4, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormInferenceVarianceExtPointwise", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=4) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "4": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Default/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Default/sweep.json index 05dfe86379d9..59f4c111ef2d 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Default/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Default/sweep.json @@ -6156,6 +6156,149 @@ "seed": 42, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdTrainingActiv3dFp32.Correctness_7" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 2, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 4, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 5, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 6, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 7, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 6, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormPointwise", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=6) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "6": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Variant2/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Variant2/sweep.json index fcca3f21fd30..456cdb0e81a8 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Variant2/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/BatchnormPointwise/Variant2/sweep.json @@ -8820,6 +8820,229 @@ "seed": 42, "reference_source": "c++ integration suite: Smoke/IntegrationGpuBatchnormFwdTrainingActiv3dFp32.Correctness_5" } + }, + { + "id": "runtime_epsilon_momentum", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 2, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 4, + "dims": [ + 2, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 5, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 6, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 7, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "double" + }, + { + "uid": 8, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 9, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 10, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 11, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 12, + "dims": [ + 1, + 3, + 1 + ], + "strides": [ + 3, + 1, + 1 + ], + "data_type": "float" + } + ] + }, + "tensor_patches": [ + { + "uid": 6, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + }, + { + "uid": 7, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "BatchnormPointwise", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=6) promoted to is_runtime_pass_by_value=true, detection value 1.0; momentum (uid=7) promoted to is_runtime_pass_by_value=true, detection value 0.9. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "6": { + "kind": "fixed", + "value": 1.0 + }, + "7": { + "kind": "fixed", + "value": 0.9 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json deleted file mode 100644 index a29de3eb2f3c..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "nodes": [ - { - "type": "PointwiseAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "operation": "add", - "in_0_tensor_uid": 0, - "in_1_tensor_uid": 1, - "in_2_tensor_uid": null, - "axis_tensor_uid": null, - "relu_lower_clip": null, - "relu_upper_clip": null, - "relu_lower_clip_slope": null, - "swish_beta": null, - "elu_alpha": null, - "softplus_beta": null - }, - "outputs": { - "out_0_tensor_uid": 2 - } - } - ], - "tensors": [ - { - "uid": 0, - "name": "in0", - "dims": [2, 4, 6, 8], - "strides": [192, 48, 8, 1], - "data_type": "float", - "virtual": false - }, - { - "uid": 1, - "name": "scalar", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 0.0 - }, - { - "uid": 2, - "name": "out0", - "dims": [2, 4, 6, 8], - "strides": [192, 48, 8, 1], - "data_type": "float", - "virtual": false - } - ], - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "" -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json deleted file mode 100644 index 3009ea13ebab..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Add/Small/Small.meta.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "format_version": 1, - "operation": "PointwiseFwdRuntimeScalar/ADD", - "generator": "generate_pointwise_runtime_scalar_golden.py", - "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", - "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scalar bundle: in_1 (uid=1) has is_runtime_pass_by_value=true with compile-time default value=0.0 (additive identity). Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (0.0) instead of the runtime value produces diverging output.", - "config": { - "operation": "add", - "dims": [2, 4, 6, 8], - "dtype": "float", - "scalar_uid": 1, - "compile_time_default": 0.0 - } -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json deleted file mode 100644 index f8789f2bec21..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "nodes": [ - { - "type": "PointwiseAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "operation": "mul", - "in_0_tensor_uid": 0, - "in_1_tensor_uid": 1, - "in_2_tensor_uid": null, - "axis_tensor_uid": null, - "relu_lower_clip": null, - "relu_upper_clip": null, - "relu_lower_clip_slope": null, - "swish_beta": null, - "elu_alpha": null, - "softplus_beta": null - }, - "outputs": { - "out_0_tensor_uid": 2 - } - } - ], - "tensors": [ - { - "uid": 0, - "name": "in0", - "dims": [2, 4, 6, 8], - "strides": [192, 48, 8, 1], - "data_type": "float", - "virtual": false - }, - { - "uid": 1, - "name": "scalar", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 1.0 - }, - { - "uid": 2, - "name": "out0", - "dims": [2, 4, 6, 8], - "strides": [192, 48, 8, 1], - "data_type": "float", - "virtual": false - } - ], - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "" -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json deleted file mode 100644 index cae1956e94b6..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/PointwiseFwdRuntimeScalar/Mul/Small/Small.meta.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "format_version": 1, - "operation": "PointwiseFwdRuntimeScalar/MUL", - "generator": "generate_pointwise_runtime_scalar_golden.py", - "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", - "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scalar bundle: in_1 (uid=1) has is_runtime_pass_by_value=true with compile-time default value=1.0 (multiplicative identity). Synthesis provides the runtime value; CPU reference executor verifies correctness. A provider using the baked default (1.0) instead of the runtime value produces diverging output.", - "config": { - "operation": "mul", - "dims": [2, 4, 6, 8], - "dtype": "float", - "scalar_uid": 1, - "compile_time_default": 1.0 - } -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Default/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Default/sweep.json index 33ee514ff160..ec5df5345f07 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Default/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Default/sweep.json @@ -4494,6 +4494,131 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuRMSNormFp32.Correctness_7" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 2, + 16, + 8, + 1 + ], + "strides": [ + 128, + 8, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 2, + "dims": [ + 1, + 1, + 1, + 8 + ], + "strides": [ + 8, + 8, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 3, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float" + }, + { + "uid": 4, + "dims": [ + 1, + 1, + 1, + 8 + ], + "strides": [ + 8, + 8, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 5, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + } + ] + }, + "tensor_patches": [ + { + "uid": 3, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "RMSNorm", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=3) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "3": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant2/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant2/sweep.json index a22444e0c13d..43ee126193e2 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant2/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant2/sweep.json @@ -3822,6 +3822,115 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuRMSNormFp32.Correctness_6" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 2, + 16, + 8, + 1 + ], + "strides": [ + 128, + 8, + 1, + 1 + ], + "data_type": "float" + }, + { + "uid": 1, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 2, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 1, + 1, + 1, + 8 + ], + "strides": [ + 8, + 8, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 4, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + } + ] + }, + "tensor_patches": [ + { + "uid": 2, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "RMSNorm", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=2) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "2": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant3/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant3/sweep.json index 15c68576970c..d28f558c3eac 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant3/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant3/sweep.json @@ -3150,6 +3150,99 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuRMSNormFp32.Correctness_8" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 1, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float" + }, + { + "uid": 2, + "dims": [ + 1, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 3, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + } + ] + }, + "tensor_patches": [ + { + "uid": 1, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "RMSNorm", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=1) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "1": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant4/sweep.json b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant4/sweep.json index 9fc9e017f812..35390cb310bf 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant4/sweep.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/RMSNorm/Variant4/sweep.json @@ -3822,6 +3822,115 @@ "seed": 1, "reference_source": "c++ integration suite: Smoke/IntegrationGpuRMSNormFp32.Correctness_9" } + }, + { + "id": "runtime_epsilon", + "values": { + "io_data_type": "bfloat16", + "tensors": [ + { + "uid": 0, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 1, + "dims": [ + 1, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 2, + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float" + }, + { + "uid": 3, + "dims": [ + 1, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + }, + { + "uid": 4, + "dims": [ + 2, + 16, + 8, + 8 + ], + "strides": [ + 1024, + 64, + 8, + 1 + ], + "data_type": "bfloat16" + } + ] + }, + "tensor_patches": [ + { + "uid": 2, + "set": { + "is_runtime_pass_by_value": true + }, + "remove": [ + "value_type", + "value" + ] + } + ], + "metadata": { + "format_version": 1, + "operation": "RMSNorm", + "generator": "manual", + "generator_version": "1.0.0", + "generated_at": "2026-07-27T00:00:00Z", + "seed": 42, + "notes": "Runtime PBV scalars: epsilon (uid=2) promoted to is_runtime_pass_by_value=true, detection value 1.0. The harness supplies the detection value(s) via inputs; both the CPU reference and the provider read from the variantPack. A provider that ignores the runtime tensor and uses any other value produces diverging output.", + "inputs": { + "2": { + "kind": "fixed", + "value": 1.0 + } + } + } } ] } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json index 7495fd9fa5c8..8418e98ee6e5 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json @@ -57,49 +57,91 @@ { "uid": 0, "name": "Q", - "dims": [2, 4, 256, 128], - "strides": [131072, 32768, 128, 1], + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], "data_type": "bfloat16", "virtual": false }, { "uid": 1, "name": "K", - "dims": [2, 4, 256, 128], - "strides": [131072, 32768, 128, 1], + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], "data_type": "bfloat16", "virtual": false }, { "uid": 2, "name": "V", - "dims": [2, 4, 256, 128], - "strides": [131072, 32768, 128, 1], + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], "data_type": "bfloat16", "virtual": false }, { "uid": 3, "name": "O", - "dims": [2, 4, 256, 128], - "strides": [131072, 32768, 128, 1], + "dims": [ + 2, + 4, + 256, + 128 + ], + "strides": [ + 131072, + 32768, + 128, + 1 + ], "data_type": "bfloat16", "virtual": false }, { "uid": 4, "name": "scale", - "dims": [1], - "strides": [1], + "dims": [ + 1 + ], + "strides": [ + 1 + ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json index c9877970814b..fc2fa174d641 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json @@ -1,21 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.1.0", "generated_at": "2026-07-21T00:00:00Z", - "reference_source": "PyTorch 2.12.0+rocm7.2", - "reference_backend": "pytorch_math_backend", - "rocm_version": "", "seed": 42, - "notes": "Runtime-with-default scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The runtime detection value is 1/sqrt(128)=0.08838834764831843 (matching the existing SdpaFwd/bhsd/bf16/hd128_nomask_batch golden data). A provider that ignores the runtime value and uses the compile-time default (2.0) produces output that diverges from the golden data.", - "config": { - "q_dims": [2, 4, 256, 128], - "v_dims": [2, 4, 256, 128], - "dtype": "bf16", - "scale_uid": 4, - "scale_value": 0.08838834764831843, - "compile_time_default": 2.0, - "gqa_ratio": 1 + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces output that diverges from the golden data.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json index dfa92e299deb..871ea7b7fe14 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json index 9dfbe1ebf674..a18f86d0dccc 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json @@ -137,9 +137,7 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true }, { "uid": 5, @@ -169,5 +167,5 @@ "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_group_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json index 06c76f1d1433..ea77a88e85f6 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json index d0b67673c527..5e80ed767169 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -155,13 +155,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_stats_SmallStats" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json index 2f3f3e4af1ec..fe866b427c8e 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json @@ -137,9 +137,7 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true }, { "uid": 5, @@ -169,5 +167,5 @@ "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_group_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json index c140170b18b2..51b7c9a2864e 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd192_causal_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json index fae7e2719f63..0d9617f7c68b 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd192_nomask_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json index 260619bed373..d4b5716ff06d 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "half", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_causal_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json index 8bbf6ea2482d..a2631964f9f5 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "half", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json index 17411785d42f..27c54a2c55a6 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -155,13 +155,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "half", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_stats_SmallStats" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json index 360ab3a25602..08bfdf7a3e63 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "half", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd192_causal_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json index 5120a5266efa..1f2c5c0dc3a0 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json @@ -137,13 +137,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "half", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd192_nomask_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json index 30b48509b7f1..b194c2130d33 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "4": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json index 5f05cea6838d..26601875a885 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json @@ -173,13 +173,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json index 30b48509b7f1..b3061b9895cf 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "10": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json index 371522451039..475f3736e95a 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json @@ -197,13 +197,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_group_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json index 30b48509b7f1..b3061b9895cf 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "10": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json index 99c862327f9b..1fb0569316d3 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json @@ -173,13 +173,11 @@ ], "data_type": "float", "virtual": false, - "is_runtime_pass_by_value": true, - "value_type": "Float32Value", - "value": 2.0 + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", - "name": "" -} + "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_nomask_batch_Small" +} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json index 30b48509b7f1..b3061b9895cf 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json @@ -1,9 +1,12 @@ { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", "generated_at": "2026-07-17T15:48:00Z", "reference_source": "synthesis+cpu_reference", - "notes": "Runtime-with-default scale bundle: scale tensor has is_runtime_pass_by_value=true with a baked compile-time default of 2.0. The CPU reference reads the scale from the variantPack (also 2.0) when attn_scale_value is null. A provider that ignores the runtime tensor and falls back to 1/sqrt(headDim) produces diverging output." + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "inputs": { + "10": { "kind": "fixed", "value": 2.0 } + } } diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py deleted file mode 100644 index ca098a4ffdb4..000000000000 --- a/dnn-providers/integration-tests/reference_data_scripts/generate_batchnorm_runtime_scalar_golden.py +++ /dev/null @@ -1,691 +0,0 @@ -#!/usr/bin/env python3 -# Copyright © Advanced Micro Devices, Inc., or its affiliates. -# SPDX-License-Identifier: MIT -""" -Batchnorm Runtime Scalar Golden Reference Bundle Generator - -Generates pre-computed reference data for batchnorm operations where a -scalar (epsilon or momentum) is provided as a runtime pass-by-value tensor -(dims=[1], strides=[1]) rather than a compile-time baked value. - -Supported scalars: - epsilon — BN inference with variance_ext; frontend REJECTS runtime epsilon - (validateScalarParameter enforces pass_by_value==true for epsilon). - This generates a NEGATIVE test bundle: the graph JSON is valid to - parse, but validate() will return INVALID_VALUE. No golden tensor - data is written for this case. - momentum — BN forward training; frontend accepts a runtime momentum tensor. - A detection value far from the compile-time default (0.5f) is used. - -Output for momentum: {base_filename}.json + .tensor{uid}.bin + .meta.json -Output for epsilon: {base_filename}.json + .meta.json (no .bin — negative test) - -Usage: - # Momentum (positive test — generates golden output) - python generate_batchnorm_runtime_scalar_golden.py \\ - --base-filename bundles/BatchnormFwdTrainingRuntimeScalar/Momentum/Small/Small \\ - --scalar momentum --scalar-value 0.9 --size 2 3 4 5 --seed 42 - - # Epsilon (negative test — generates graph JSON only, no golden output) - python generate_batchnorm_runtime_scalar_golden.py \\ - --base-filename bundles/BatchnormFwdInferenceRuntimeScalar/Epsilon/Small/Small \\ - --scalar epsilon --scalar-value 1.0 --size 2 3 4 5 --seed 42 -""" - -import argparse -import datetime -import hashlib -import json -import os -import sys - -import torch -import torch.nn.functional as F - -# Bump when generator logic changes in a way that affects output data. -# 1.0.0 — Initial: BN momentum (positive) and epsilon (negative) runtime scalar bundles -# 1.1.0 — Epsilon bundle now writes golden .bin files; mean_out/inv_var_out derived -# from execute_batchnorm_fwd_training (not recomputed independently) -GENERATOR_VERSION = "1.1.0" - - -def compute_contiguous_strides(dims): - strides = [] - stride = 1 - for d in reversed(dims): - strides.append(stride) - stride *= d - strides.reverse() - return strides - - -def save_tensor_bin(tensor, path): - t = tensor.contiguous().cpu().float() - raw = t.numpy().tobytes() - with open(path, "wb") as f: - f.write(raw) - - -def _get_generator_sha256(): - script_path = os.path.abspath(__file__) - with open(script_path, "rb") as f: - return hashlib.sha256(f.read()).hexdigest() - - -# --------------------------------------------------------------------------- -# Epsilon bundle (negative test — no golden output) -# --------------------------------------------------------------------------- - - -def build_epsilon_graph_json(x_dims): - """BN inference (variance_ext style) with epsilon as a runtime tensor. - - The frontend's validateScalarParameter will reject this graph at validate() - time with INVALID_VALUE because epsilon must be pass_by_value==true. - No golden tensor output is generated. - - Tensor UIDs: - 0 = x (input) - 1 = mean (input) - 2 = inv_variance (input) - 3 = scale (input) - 4 = bias (input) - 5 = epsilon (runtime scalar — no value_type/value fields) - 6 = y (output) - """ - channel_dims = [1, x_dims[1]] + [1] * (len(x_dims) - 2) - channel_strides = compute_contiguous_strides(channel_dims) - x_strides = compute_contiguous_strides(x_dims) - - tensors = [ - { - "uid": 0, - "name": "x", - "dims": x_dims, - "strides": x_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 1, - "name": "mean", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 2, - "name": "variance", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 3, - "name": "scale", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 4, - "name": "bias", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 5, - "name": "epsilon", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": False, - # Intentionally no "value_type"/"value" — runtime form. - # The frontend will reject this via validateScalarParameter. - }, - { - "uid": 6, - "name": "y", - "dims": x_dims, - "strides": x_strides, - "data_type": "float", - "virtual": False, - }, - ] - - return { - "nodes": [ - { - "type": "BatchnormInferenceAttributesVarianceExt", - "compute_data_type": "float", - "name": "", - "inputs": { - "x_tensor_uid": 0, - "mean_tensor_uid": 1, - "variance_tensor_uid": 2, - "scale_tensor_uid": 3, - "bias_tensor_uid": 4, - "epsilon_tensor_uid": 5, - }, - "outputs": { - "y_tensor_uid": 6, - }, - } - ], - "tensors": tensors, - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "", - } - - -def execute_batchnorm_inference_variance_ext(x, mean, variance, scale, bias, epsilon): - """BN inference (variance_ext form) reference computation. - - Computes y = scale * (x - mean) / sqrt(variance + epsilon) + bias. - This matches what the provider kernel does when it receives variance + epsilon - and computes inv_variance internally. - """ - x_f = x.float() - inv_var = 1.0 / torch.sqrt(variance.float() + float(epsilon)) - y = scale.float() * (x_f - mean.float()) * inv_var + bias.float() - return y.to(x.dtype) - - -def generate_epsilon_bundle(base_filename, x_dims, scalar_value, seed): - """Generate the epsilon negative-test bundle. - - Writes graph JSON + golden .bin files + meta. The graph uses a runtime - epsilon (no value_type/value in JSON), so validate() returns INVALID_VALUE - and a correct provider never executes. Golden outputs are computed with - the correct epsilon (1e-5), so if a broken provider bypasses validation - and executes with epsilon=scalar_value instead, its output diverges. - """ - os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) - - print( - f"Generating BN epsilon runtime scalar bundle (NEGATIVE TEST): {base_filename}" - ) - print(f" x_dims: {x_dims}, epsilon uid=5, detection value={scalar_value}") - print( - f" Golden computed with correct epsilon=1e-5; broken provider using " - f"epsilon={scalar_value} produces detectably wrong output." - ) - - C = x_dims[1] - channel_dims = [1, C] + [1] * (len(x_dims) - 2) - - rng = torch.Generator().manual_seed(seed) - x = torch.empty(x_dims, dtype=torch.float32).uniform_(-1.0, 1.0, generator=rng) - mean = torch.empty(channel_dims, dtype=torch.float32).uniform_( - -0.5, 0.5, generator=rng - ) - # variance must be non-negative - variance = torch.empty(channel_dims, dtype=torch.float32).uniform_( - 0.1, 2.0, generator=rng - ) - scale = torch.empty(channel_dims, dtype=torch.float32).uniform_( - 0.5, 2.0, generator=rng - ) - bias = torch.empty(channel_dims, dtype=torch.float32).uniform_( - -0.5, 0.5, generator=rng - ) - # epsilon runtime tensor: detection value, but golden computed with correct 1e-5 - epsilon_tensor = torch.full([1], scalar_value, dtype=torch.float32) - correct_epsilon = 1e-5 - - y = execute_batchnorm_inference_variance_ext( - x, mean, variance, scale, bias, correct_epsilon - ) - - graph_json = build_epsilon_graph_json(x_dims) - json_path = f"{base_filename}.json" - with open(json_path, "w") as f: - json.dump(graph_json, f, indent=4) - f.write("\n") - print(f" Graph JSON: {json_path}") - - # Write .bin files: uid order matches tensor UIDs in graph JSON - # uid 0=x, 1=mean, 2=variance, 3=scale, 4=bias, 5=epsilon, 6=y - tensor_data = [ - ("x", x, 0), - ("mean", mean, 1), - ("variance", variance, 2), - ("scale", scale, 3), - ("bias", bias, 4), - ("epsilon", epsilon_tensor, 5), - ("y", y, 6), - ] - for name, tensor, uid in tensor_data: - bin_path = f"{base_filename}.tensor{uid}.bin" - save_tensor_bin(tensor, bin_path) - print(f" tensor{uid} ({name}): {bin_path} ({os.path.getsize(bin_path)} bytes)") - - meta = { - "format_version": 1, - "operation": "BatchnormFwdInferenceRuntimeScalar/Epsilon", - "generator": "generate_batchnorm_runtime_scalar_golden.py", - "generator_sha256": _get_generator_sha256(), - "generator_version": GENERATOR_VERSION, - "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%dT%H:%M:%SZ" - ), - "reference_source": f"PyTorch {torch.__version__}", - "reference_strategy": "pytorch_bn_inference_variance_ext", - "rocm_version": "", - "seed": seed, - "notes": ( - "NEGATIVE TEST: epsilon (uid=5) is a runtime tensor (no value_type/value fields). " - "hipDNN's validateScalarParameter requires epsilon to be pass_by_value==true, so " - f"validate() must return INVALID_VALUE. Golden output is computed with correct " - f"epsilon=1e-5. Detection value={scalar_value} is intentionally far from 1e-5: " - "a broken provider that bypasses validation and executes with the wrong epsilon " - "will produce output that diverges from the golden data." - ), - "config": { - "scalar": "epsilon", - "x_dims": x_dims, - "scalar_uid": 5, - "scalar_value": scalar_value, - "correct_epsilon": 1e-5, - "expected_failure": "validate", - }, - } - meta_path = f"{base_filename}.meta.json" - with open(meta_path, "w") as f: - json.dump(meta, f, indent=4) - f.write("\n") - print(f" Meta JSON: {meta_path}") - - -# --------------------------------------------------------------------------- -# Momentum bundle (positive test — golden output generated) -# --------------------------------------------------------------------------- - - -def execute_batchnorm_fwd_training( - x, scale, bias, prev_running_mean, prev_running_var, momentum -): - """BN forward training reference via PyTorch batch_norm (training=True). - - Returns (y, mean_out, inv_var_out, next_running_mean, next_running_var). - mean_out and inv_var_out are derived from the same population statistics - that PyTorch's batch_norm kernel uses internally, ensuring they match - provider output. - """ - C = x.shape[1] - reduce_dims = [d for d in range(x.ndim) if d != 1] - shape = prev_running_mean.shape - - # Compute batch statistics (population, matching PyTorch's internal kernel) - x_f = x.float() - mean_out = x_f.mean(dim=reduce_dims, keepdim=True) - var_batch = x_f.var(dim=reduce_dims, unbiased=False, keepdim=True) - inv_var_out = 1.0 / torch.sqrt(var_batch + 1e-5) - - # PyTorch batch_norm expects 1-D running stats - rm = prev_running_mean.view(C).clone().float() - rv = prev_running_var.view(C).clone().float() - s = scale.view(C).float() - b = bias.view(C).float() - - y = F.batch_norm( - x_f, - rm, - rv, - weight=s, - bias=b, - training=True, - momentum=float(momentum), - eps=1e-5, - ) - - # After batch_norm(training=True), rm and rv are updated in-place by PyTorch - next_running_mean = rm.view(shape) - next_running_var = rv.view(shape) - - return ( - y.to(x.dtype), - mean_out.view(shape), - inv_var_out.view(shape), - next_running_mean, - next_running_var, - ) - - -def build_momentum_graph_json(x_dims, momentum_value): - """BN forward training with momentum as a runtime tensor. - - Tensor UIDs: - 0 = x (input) - 1 = scale (input) - 2 = bias (input) - 3 = epsilon (compile-time scalar, value=1e-5) - 4 = prev_running_mean (input) - 5 = prev_running_var (input) - 6 = momentum (runtime scalar — no value_type/value fields) - 7 = y (output) - 8 = mean_out (output) - 9 = inv_var_out (output) - 10 = next_running_mean (output) - 11 = next_running_var (output) - """ - x_strides = compute_contiguous_strides(x_dims) - channel_dims = [1, x_dims[1]] + [1] * (len(x_dims) - 2) - channel_strides = compute_contiguous_strides(channel_dims) - - tensors = [ - { - "uid": 0, - "name": "x", - "dims": x_dims, - "strides": x_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 1, - "name": "scale", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 2, - "name": "bias", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - # epsilon stays compile-time — only momentum is runtime in this bundle - { - "uid": 3, - "name": "epsilon", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": False, - "value_type": "Float32Value", - "value": 1e-5, - }, - { - "uid": 4, - "name": "prev_running_mean", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 5, - "name": "prev_running_var", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 6, - "name": "momentum", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": False, - # Intentionally no "value_type"/"value" — runtime form. - }, - { - "uid": 7, - "name": "y", - "dims": x_dims, - "strides": x_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 8, - "name": "mean_out", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 9, - "name": "inv_var_out", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 10, - "name": "next_running_mean", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - { - "uid": 11, - "name": "next_running_var", - "dims": channel_dims, - "strides": channel_strides, - "data_type": "float", - "virtual": False, - }, - ] - - return { - "nodes": [ - { - "type": "BatchnormAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "x_tensor_uid": 0, - "scale_tensor_uid": 1, - "bias_tensor_uid": 2, - "epsilon_tensor_uid": 3, - "peer_stats_tensor_uid": [], - "prev_running_mean_tensor_uid": 4, - "prev_running_variance_tensor_uid": 5, - "momentum_tensor_uid": 6, - }, - "outputs": { - "y_tensor_uid": 7, - "mean_tensor_uid": 8, - "inv_variance_tensor_uid": 9, - "next_running_mean_tensor_uid": 10, - "next_running_variance_tensor_uid": 11, - }, - } - ], - "tensors": tensors, - "io_data_type": "float", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "", - } - - -def generate_momentum_bundle( - base_filename, x_dims, scalar_value, seed, min_val, max_val -): - """Generate the momentum positive-test bundle (graph JSON + .bin + meta).""" - os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) - - print(f"Generating BN momentum runtime scalar bundle: {base_filename}") - print(f" x_dims: {x_dims}, momentum uid=6, detection value={scalar_value}") - print(f" seed: {seed}, input range: [{min_val}, {max_val}]") - - rng = torch.Generator().manual_seed(seed) - C = x_dims[1] - channel_dims = [1, C] + [1] * (len(x_dims) - 2) - - x = torch.empty(x_dims, dtype=torch.float32).uniform_( - min_val, max_val, generator=rng - ) - scale = torch.empty(channel_dims, dtype=torch.float32).uniform_( - 0.5, 2.0, generator=rng - ) - bias = torch.empty(channel_dims, dtype=torch.float32).uniform_( - -0.5, 0.5, generator=rng - ) - prev_running_mean = torch.empty(channel_dims, dtype=torch.float32).uniform_( - -1.0, 1.0, generator=rng - ) - prev_running_var = torch.empty(channel_dims, dtype=torch.float32).uniform_( - 0.1, 2.0, generator=rng - ) - momentum_tensor = torch.full([1], scalar_value, dtype=torch.float32) - - y, mean_out, inv_var_out, next_running_mean, next_running_var = ( - execute_batchnorm_fwd_training( - x, scale, bias, prev_running_mean, prev_running_var, scalar_value - ) - ) - - assert not torch.isnan(y).any(), "NaN in y" - assert not torch.isinf(y).any(), "Inf in y" - - # Write tensor .bin files - tensor_data = [ - ("x", x, 0), - ("scale", scale, 1), - ("bias", bias, 2), - # uid=3 is epsilon (compile-time, baked in JSON — still write bin for input) - ("epsilon", torch.tensor([1e-5]), 3), - ("prev_running_mean", prev_running_mean, 4), - ("prev_running_var", prev_running_var, 5), - ("momentum", momentum_tensor, 6), - ("y", y, 7), - ("mean_out", mean_out, 8), - ("inv_var_out", inv_var_out, 9), - ("next_running_mean", next_running_mean, 10), - ("next_running_var", next_running_var, 11), - ] - for name, tensor, uid in tensor_data: - bin_path = f"{base_filename}.tensor{uid}.bin" - save_tensor_bin(tensor, bin_path) - size_bytes = os.path.getsize(bin_path) - print(f" {name} (uid={uid}): {list(tensor.shape)} -> {size_bytes} bytes") - - graph_json = build_momentum_graph_json(x_dims, scalar_value) - json_path = f"{base_filename}.json" - with open(json_path, "w") as f: - json.dump(graph_json, f, indent=4) - f.write("\n") - print(f" Graph JSON: {json_path}") - - rocm_ver = "" - if "+rocm" in torch.__version__: - rocm_ver = torch.__version__.split("+rocm")[1] - - meta = { - "format_version": 1, - "operation": "BatchnormFwdTrainingRuntimeScalar/Momentum", - "generator": "generate_batchnorm_runtime_scalar_golden.py", - "generator_sha256": _get_generator_sha256(), - "generator_version": GENERATOR_VERSION, - "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%dT%H:%M:%SZ" - ), - "reference_source": f"PyTorch {torch.__version__}", - "reference_strategy": "pytorch_batch_norm_training", - "rocm_version": rocm_ver, - "seed": seed, - "notes": ( - "Runtime scalar bundle: momentum (uid=6) is a runtime tensor (no value_type/value " - f"field in JSON). Detection value={scalar_value} is intentionally far from the " - "compile-time default (0.5) to expose providers that ignore the runtime momentum." - ), - "config": { - "scalar": "momentum", - "x_dims": x_dims, - "scalar_uid": 6, - "scalar_value": scalar_value, - }, - } - meta_path = f"{base_filename}.meta.json" - with open(meta_path, "w") as f: - json.dump(meta, f, indent=4) - f.write("\n") - print(f" Meta JSON: {meta_path}") - - -# --------------------------------------------------------------------------- -# Entry point -# --------------------------------------------------------------------------- - - -def main(): - parser = argparse.ArgumentParser( - description=( - "Generate batchnorm runtime scalar golden reference bundles. " - "For epsilon: generates a negative-test bundle (graph JSON only, no golden). " - "For momentum: generates a positive-test bundle with full golden output." - ) - ) - parser.add_argument( - "--base-filename", - required=True, - help="Path prefix for output files (no extension)", - ) - parser.add_argument( - "--scalar", - required=True, - choices=["epsilon", "momentum"], - help="Which scalar to make runtime: 'epsilon' (negative test) or 'momentum' (positive test)", - ) - parser.add_argument( - "--scalar-value", - type=float, - required=True, - help=( - "Detection value for the runtime scalar tensor. " - "Use a value far from the compile-time default: " - "epsilon default=1e-5 (use ~1.0), momentum default=0.5 (use ~0.9)." - ), - ) - parser.add_argument( - "--size", - nargs="+", - type=int, - required=True, - help="Dimensions of the x tensor (e.g. --size 2 3 4 5)", - ) - parser.add_argument("--seed", type=int, default=42) - parser.add_argument("--min", type=float, default=0.1, dest="min_val") - parser.add_argument("--max", type=float, default=1.0, dest="max_val") - args = parser.parse_args() - - if args.scalar == "epsilon": - generate_epsilon_bundle( - base_filename=args.base_filename, - x_dims=args.size, - scalar_value=args.scalar_value, - seed=args.seed, - ) - else: - generate_momentum_bundle( - base_filename=args.base_filename, - x_dims=args.size, - scalar_value=args.scalar_value, - seed=args.seed, - min_val=args.min_val, - max_val=args.max_val, - ) - - print("\nDone.") - - -if __name__ == "__main__": - main() diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py deleted file mode 100644 index 49ca0b686d5e..000000000000 --- a/dnn-providers/integration-tests/reference_data_scripts/generate_pointwise_runtime_scalar_golden.py +++ /dev/null @@ -1,329 +0,0 @@ -#!/usr/bin/env python3 -# Copyright © Advanced Micro Devices, Inc., or its affiliates. -# SPDX-License-Identifier: MIT -""" -Pointwise Runtime Scalar Golden Reference Bundle Generator - -Generates pre-computed reference data for pointwise operations where one -operand is a runtime pass-by-value scalar tensor (dims=[1], strides=[1]), -rather than a compile-time baked scalar. - -Supported operations: - add — out = in0 + scalar - mul — out = in0 * scalar - -Output: {base_filename}.json + {base_filename}.tensor{uid}.bin + {base_filename}.meta.json - -Usage: - python generate_pointwise_runtime_scalar_golden.py \\ - --base-filename bundles/PointwiseFwdRuntimeScalar/Add/Small/Small \\ - --operation add --dims 2 4 6 8 --scalar-value 100.0 --dtype float --seed 42 - - python generate_pointwise_runtime_scalar_golden.py \\ - --base-filename bundles/PointwiseFwdRuntimeScalar/Mul/Small/Small \\ - --operation mul --dims 2 4 6 8 --scalar-value 10.0 --dtype float --seed 42 -""" - -import argparse -import datetime -import hashlib -import json -import os -import sys - -import torch - -# Bump when generator logic changes in a way that affects output data. -# 1.0.0 — Initial: pointwise ADD and MUL with runtime scalar operand (in_1) -GENERATOR_VERSION = "1.0.0" - -DTYPE_MAP = { - "float": {"torch": torch.float32, "json": "float", "bytes": 4}, - "half": {"torch": torch.float16, "json": "half", "bytes": 2}, - "bfloat16": {"torch": torch.bfloat16, "json": "bfloat16", "bytes": 2}, -} - -OPERATION_MAP = { - "add": "add", - "mul": "mul", -} - - -def compute_contiguous_strides(dims): - strides = [] - stride = 1 - for d in reversed(dims): - strides.append(stride) - stride *= d - strides.reverse() - return strides - - -def execute_pointwise(in0, scalar_val, operation, compute_dtype): - in0_f = in0.to(compute_dtype) - scalar = torch.full([1], scalar_val, dtype=compute_dtype) - if operation == "add": - out = in0_f + scalar - elif operation == "mul": - out = in0_f * scalar - else: - raise ValueError(f"Unsupported operation: {operation}") - return out.to(in0.dtype), scalar - - -def save_tensor_bin(tensor, path): - t = tensor.contiguous().cpu() - if t.dtype in (torch.bfloat16, torch.float16): - raw = t.view(torch.uint8).numpy().tobytes() - else: - raw = t.numpy().tobytes() - with open(path, "wb") as f: - f.write(raw) - - -def build_graph_json(dims, strides, scalar_val, operation, dtype_str): - # UIDs: - # 0 = in0 (main input tensor) - # 1 = in1 (runtime scalar, dims=[1], strides=[1]) - # 2 = out0 (output tensor) - tensors = [ - { - "uid": 0, - "name": "in0", - "dims": dims, - "strides": strides, - "data_type": dtype_str, - "virtual": False, - }, - { - "uid": 1, - "name": "scalar", - "dims": [1], - "strides": [1], - "data_type": "float", - "virtual": False, - # No "value_type" / "value" fields — this is the runtime form - }, - { - "uid": 2, - "name": "out0", - "dims": dims, - "strides": strides, - "data_type": dtype_str, - "virtual": False, - }, - ] - - graph = { - "nodes": [ - { - "type": "PointwiseAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "operation": OPERATION_MAP[operation], - "in_0_tensor_uid": 0, - "in_1_tensor_uid": 1, - "in_2_tensor_uid": None, - "axis_tensor_uid": None, - "relu_lower_clip": None, - "relu_upper_clip": None, - "relu_lower_clip_slope": None, - "swish_beta": None, - "elu_alpha": None, - "softplus_beta": None, - }, - "outputs": { - "out_0_tensor_uid": 2, - }, - } - ], - "tensors": tensors, - "io_data_type": dtype_str, - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "", - } - return graph - - -def _get_generator_sha256(): - script_path = os.path.abspath(__file__) - with open(script_path, "rb") as f: - return hashlib.sha256(f.read()).hexdigest() - - -def build_meta_json(config, pytorch_version): - rocm_ver = "" - if "+rocm" in pytorch_version: - rocm_ver = pytorch_version.split("+rocm")[1] - - return { - "format_version": 1, - "operation": f"PointwiseFwdRuntimeScalar/{config['operation'].upper()}", - "generator": "generate_pointwise_runtime_scalar_golden.py", - "generator_sha256": _get_generator_sha256(), - "generator_version": GENERATOR_VERSION, - "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( - "%Y-%m-%dT%H:%M:%SZ" - ), - "reference_source": f"PyTorch {pytorch_version}", - "reference_strategy": "pytorch_elementwise", - "rocm_version": rocm_ver, - "seed": config["seed"], - "notes": ( - f"Runtime scalar bundle: in_1 (uid=1) is a runtime pass-by-value tensor " - f"(no value_type/value fields in JSON). Detection value={config['scalar_value']} is " - f"intentionally far from any compile-time default to expose providers that " - f"ignore the runtime scalar." - ), - "config": { - "operation": config["operation"], - "dims": config["dims"], - "dtype": config["dtype"], - "scalar_uid": 1, - "scalar_value": config["scalar_value"], - }, - } - - -def generate_bundle( - base_filename, - operation, - dims, - dtype="float", - scalar_value=100.0, - seed=42, - min_val=0.1, - max_val=1.0, -): - if dtype not in DTYPE_MAP: - print( - f"ERROR: --dtype must be one of {list(DTYPE_MAP.keys())} (got '{dtype}')", - file=sys.stderr, - ) - sys.exit(1) - if operation not in OPERATION_MAP: - print( - f"ERROR: --operation must be one of {list(OPERATION_MAP.keys())} (got '{operation}')", - file=sys.stderr, - ) - sys.exit(1) - - dtype_info = DTYPE_MAP[dtype] - torch_dtype = dtype_info["torch"] - strides = compute_contiguous_strides(dims) - - os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) - - print(f"Generating pointwise runtime scalar bundle: {base_filename}") - print(f" operation: {operation}") - print(f" dims: {dims}, strides: {strides}, dtype: {dtype}") - print(f" scalar uid=1, value={scalar_value} (runtime — no value field in JSON)") - print(f" seed: {seed}, input range: [{min_val}, {max_val}]") - - rng = torch.Generator().manual_seed(seed) - in0 = torch.empty(dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) - - out0, scalar_tensor = execute_pointwise(in0, scalar_value, operation, torch.float32) - - assert not torch.isnan(out0).any(), "NaN in output" - assert not torch.isinf(out0).any(), "Inf in output" - - # Write tensor .bin files - for name, tensor, uid in [ - ("in0", in0, 0), - ("scalar", scalar_tensor, 1), - ("out0", out0, 2), - ]: - bin_path = f"{base_filename}.tensor{uid}.bin" - save_tensor_bin(tensor, bin_path) - size_bytes = os.path.getsize(bin_path) - print( - f" {name} (uid={uid}): {list(tensor.shape)} {tensor.dtype} -> {size_bytes} bytes" - ) - - # Write graph JSON - graph_json = build_graph_json( - dims, strides, scalar_value, operation, dtype_info["json"] - ) - json_path = f"{base_filename}.json" - with open(json_path, "w") as f: - json.dump(graph_json, f, indent=4) - f.write("\n") - print(f" Graph JSON: {json_path}") - - # Write meta JSON - config = { - "operation": operation, - "dims": dims, - "dtype": dtype, - "scalar_value": scalar_value, - "seed": seed, - } - meta_json = build_meta_json(config, torch.__version__) - meta_path = f"{base_filename}.meta.json" - with open(meta_path, "w") as f: - json.dump(meta_json, f, indent=4) - f.write("\n") - print(f" Meta JSON: {meta_path}") - - -def main(): - parser = argparse.ArgumentParser( - description="Generate pointwise runtime scalar golden reference bundles" - ) - parser.add_argument( - "--base-filename", - required=True, - help="Path prefix for output files (no extension)", - ) - parser.add_argument( - "--operation", - required=True, - choices=list(OPERATION_MAP.keys()), - help="Pointwise operation: add or mul", - ) - parser.add_argument( - "--dims", - nargs="+", - type=int, - required=True, - help="Dimensions of in0 tensor (e.g. --dims 2 4 6 8)", - ) - parser.add_argument( - "--scalar-value", - type=float, - required=True, - help=( - "Value for the runtime scalar tensor (uid=1). " - "Use a value far from any compile-time default to enable detection " - "(e.g. 100.0 for ADD, 10.0 for MUL)." - ), - ) - parser.add_argument( - "--dtype", - default="float", - choices=list(DTYPE_MAP.keys()), - help="Data type for in0 and out0 tensors (default: float)", - ) - parser.add_argument("--seed", type=int, default=42) - parser.add_argument("--min", type=float, default=0.1, dest="min_val") - parser.add_argument("--max", type=float, default=1.0, dest="max_val") - args = parser.parse_args() - - generate_bundle( - base_filename=args.base_filename, - operation=args.operation, - dims=args.dims, - dtype=args.dtype, - scalar_value=args.scalar_value, - seed=args.seed, - min_val=args.min_val, - max_val=args.max_val, - ) - print("\nDone.") - - -if __name__ == "__main__": - main() diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py similarity index 100% rename from dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_golden.py rename to dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py diff --git a/dnn-providers/integration-tests/reference_data_scripts/requirements.txt b/dnn-providers/integration-tests/reference_data_scripts/requirements.txt new file mode 100644 index 000000000000..bca1994e52a1 --- /dev/null +++ b/dnn-providers/integration-tests/reference_data_scripts/requirements.txt @@ -0,0 +1,7 @@ +# Reference data generation scripts require PyTorch. +# +# Install a ROCm-enabled wheel matching your system ROCm version, e.g.: +# ROCm 7.x: pip install --index-url https://download.pytorch.org/whl/rocm7.0 torch +# or a CPU-only wheel for local development: +# pip install torch +torch diff --git a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp index a38c885c2084..9912982d29c7 100644 --- a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp +++ b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp @@ -558,6 +558,86 @@ inline nlohmann::json expandTemplateGraph(const nlohmann::json& templateJson, return expanded; } +// Applies structural tensor patches declared in a sweep case's "tensor_patches" array. +// Each patch targets a tensor by uid and supports "set" (upsert fields) and "remove" (erase +// fields). Called after expandTemplateGraph so placeholders are already resolved, and before +// buildGraphBuffer so the flatbuffer has not yet been sealed. +inline void applyTensorPatches(nlohmann::json& expandedGraph, const nlohmann::json& caseJson) +{ + if(!caseJson.contains("tensor_patches") || !caseJson.at("tensor_patches").is_array()) + { + return; + } + + if(!expandedGraph.contains("tensors") || !expandedGraph.at("tensors").is_array()) + { + return; + } + + for(const auto& patch : caseJson.at("tensor_patches")) + { + if(!patch.is_object() || !patch.contains("uid") || !patch.at("uid").is_number_integer()) + { + throw std::runtime_error("tensor_patch entry is missing an integer uid"); + } + + const auto targetUid = patch.at("uid").get(); + bool found = false; + + for(auto& tensor : expandedGraph.at("tensors")) + { + if(!tensor.contains("uid") || tensor.at("uid").get() != targetUid) + { + continue; + } + + if(patch.contains("set") && patch.at("set").is_object()) + { + for(const auto& [key, val] : patch.at("set").items()) + { + tensor[key] = val; + } + } + + if(patch.contains("remove") && patch.at("remove").is_array()) + { + for(const auto& key : patch.at("remove")) + { + if(key.is_string()) + { + tensor.erase(key.get()); + } + } + } + + found = true; + break; + } + + if(!found) + { + throw std::runtime_error("tensor_patch uid " + std::to_string(targetUid) + + " not found in expanded graph"); + } + } + + // Invariant: a tensor with is_runtime_pass_by_value=true must not also carry a baked + // value_type or value — if it does, both the CPU reference and the provider silently + // short-circuit to the baked value and the runtime path is never exercised. + for(const auto& tensor : expandedGraph.at("tensors")) + { + if(tensor.value("is_runtime_pass_by_value", false) + && (tensor.contains("value_type") || tensor.contains("value"))) + { + const auto uid = tensor.value("uid", int64_t{-1}); + throw std::runtime_error( + "tensor uid " + std::to_string(uid) + + " has is_runtime_pass_by_value=true but still carries value_type or value;" + " remove them from the tensor_patches 'remove' list or the template"); + } + } +} + inline const nlohmann::json* findSweepCase(const nlohmann::json& sweepJson, const std::string& caseId) { @@ -707,6 +787,7 @@ inline LoadResult loadIntegrationTestBundle(const DiscoveredBundle& discovered) { expandedGraph = detail::expandTemplateGraph(*templateJson, *caseJson, discovered); goldenDirectory = detail::resolveSweepGoldenDirectory(discovered.jsonPath, *caseJson); + detail::applyTensorPatches(expandedGraph, *caseJson); } catch(const std::exception&) { From 7831fd789b6f2b233727e4abbb9b5517bd01af59 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Mon, 27 Jul 2026 14:58:03 -0600 Subject: [PATCH 4/9] style(hipdnn): fix clang-format indentation in tensor patch check A continuation line in applyTensorPatches's invariant-check error message was indented two spaces short of clang-format's expected alignment for the concatenated string literals, which CI's clang-format hook flagged. The local pre-commit should now be configured correctly and catch this type of issue in advance. ALMIOPEN-2267 --- .../src/harness/bundle/IntegrationTestBundle.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp index 9912982d29c7..6739d2c72340 100644 --- a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp +++ b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp @@ -633,7 +633,7 @@ inline void applyTensorPatches(nlohmann::json& expandedGraph, const nlohmann::js throw std::runtime_error( "tensor uid " + std::to_string(uid) + " has is_runtime_pass_by_value=true but still carries value_type or value;" - " remove them from the tensor_patches 'remove' list or the template"); + " remove them from the tensor_patches 'remove' list or the template"); } } } From 8efc596dd63e0d2ba4ff96090877e648bb9d4914 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Mon, 27 Jul 2026 17:25:01 -0600 Subject: [PATCH 5/9] fix(hipdnn): fix compile error and stale bake-in in SDPA runtime-scale tests TestSdpaFwdPlan.cpp passed an extra std::nullopt at two SdpaFwdParams call sites, shifting every subsequent positional argument by one slot and causing a compile failure whenever SDPA is enabled. generate_sdpa_runtime_scale_test_bundle.py still baked a compile-time value_type/value onto the scale tensor alongside is_runtime_pass_by_value, even though the checked-in bundle data had already dropped those fields. A tensor can't carry both without silently short-circuiting to the baked value, so the runtime injection path this bundle is meant to exercise would never actually run. The script now matches the corrected bundle data and the pattern already enforced for the Batchnorm and RMSNorm runtime-scalar tests. ALMIOPEN-2267 --- .../generate_sdpa_runtime_scale_test_bundle.py | 12 ++++-------- .../utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp | 2 -- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py index 57277acbf099..105965e8b0a1 100644 --- a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py +++ b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py @@ -91,11 +91,11 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): """Build the SDPA graph JSON with scale wired as a runtime tensor. Key difference from the compile-time variant (generate_sdpa_fwd_golden.py): - - scale_tensor_uid = UID_SCALE (runtime-with-default PBV tensor) - - scale tensor carries value_type/value=2.0 as a wrong compile-time bake-in + - scale_tensor_uid = UID_SCALE (pure runtime PBV tensor, no baked fallback) - attn_scale_value = null (forces CPU reference to read from variantPack) - A provider that ignores the runtime tensor and reads the bake-in (2.0) or falls - back to 1/sqrt(headDim) produces output that diverges from the CPU reference. + A provider that falls back to a compile-time default (e.g. 1/sqrt(headDim)) + instead of reading the runtime tensor produces output that diverges from the + CPU reference. """ tensors = [ { @@ -138,10 +138,6 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "data_type": "float", "virtual": False, "is_runtime_pass_by_value": True, - "value_type": "Float32Value", - # Compile-time bake-in: intentionally wrong so a provider that ignores the - # runtime tensor and reads this value instead produces detectably wrong output. - "value": 2.0, }, ] diff --git a/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp b/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp index fb6ec11011f2..1f0c07b14127 100644 --- a/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp +++ b/projects/hipdnn/test_sdk/tests/utilities/cpu_graph_executor/TestSdpaFwdPlan.cpp @@ -44,7 +44,6 @@ TEST(TestSdpaFwdPlan, ExecutePlan) *tensorMap.at(nodeAttributes->v_tensor_uid()), *tensorMap.at(nodeAttributes->o_tensor_uid()), std::nullopt, - std::nullopt, /*leftBound=*/-1, /*rightBound=*/-1, /*topLeftAlignment=*/true); @@ -142,7 +141,6 @@ TEST(TestSdpaFwdPlan, ExecutePlanWithCausalMask) *tensorMap.at(nodeAttributes->v_tensor_uid()), *tensorMap.at(nodeAttributes->o_tensor_uid()), std::nullopt, - std::nullopt, /*leftBound=*/-1, /*rightBound=*/0, /*topLeftAlignment=*/true); From 0fade03686f1570a2d691b15fbc1b525e41877c5 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Tue, 28 Jul 2026 08:11:27 -0600 Subject: [PATCH 6/9] fix(hipdnn): remove redundant scalar attn_scale calls from SDPA tests Three SDPA integration tests set attn_scale as both a tensor and a scalar on the same node, which SdpaFwdNode and SdpaBwdNode validation rejects since a graph cannot specify attn_scale both ways at once. Removing the leftover scalar-form call and its corresponding attn_scale_value assertion leaves each test exercising only the tensor pass-by-value form it is meant to cover. ALMIOPEN-2267 --- .../tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp | 4 ---- projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp | 3 --- .../tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp | 3 --- 3 files changed, 10 deletions(-) diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp index b42071111ea6..32326073ecf3 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp @@ -391,7 +391,6 @@ TEST_F(IntegrationSdpaBwdDescriptorLowering, SdpaBwdWithAllOptionalTensorsAndSca sdpaAttrs.set_padding_mask(true); sdpaAttrs.set_causal_mask(true); sdpaAttrs.set_causal_mask_bottom_right(true); - sdpaAttrs.set_attn_scale(0.125f); sdpaAttrs.set_diagonal_band_left_bound(0); sdpaAttrs.set_diagonal_band_right_bound(128); sdpaAttrs.set_diagonal_alignment(DiagonalAlignment::BOTTOM_RIGHT); @@ -581,9 +580,6 @@ TEST_F(IntegrationSdpaBwdDescriptorLowering, SdpaBwdWithAllOptionalTensorsAndSca ASSERT_TRUE(sdpa->dropout_probability.has_value()); EXPECT_FLOAT_EQ(sdpa->dropout_probability.value(), 0.1f); - ASSERT_TRUE(sdpa->attn_scale_value.has_value()); - EXPECT_FLOAT_EQ(sdpa->attn_scale_value.value(), 0.125f); - // Integer scalars ASSERT_TRUE(sdpa->left_bound.has_value()); EXPECT_EQ(sdpa->left_bound.value(), 0); diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp index 7c228f242612..fdeb9ad18b9a 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp @@ -324,7 +324,6 @@ TEST_F(IntegrationSdpaBwdLifting, SdpaBwdWithAllOptionalAttributesViaCApi) .set_padding_mask(true) .set_causal_mask(true) .set_causal_mask_bottom_right(true) - .set_attn_scale(0.125f) .set_diagonal_band_left_bound(-1) .set_diagonal_band_right_bound(1) .set_diagonal_alignment(DiagonalAlignment::BOTTOM_RIGHT); @@ -452,8 +451,6 @@ TEST_F(IntegrationSdpaBwdLifting, SdpaBwdWithAllOptionalAttributesViaCApi) // Scalar values ASSERT_TRUE(attrs.dropout_probability.has_value()); EXPECT_FLOAT_EQ(attrs.dropout_probability.value(), 0.1f); - ASSERT_TRUE(attrs.attn_scale_value.has_value()); - EXPECT_FLOAT_EQ(attrs.attn_scale_value.value(), 0.125f); ASSERT_TRUE(attrs.left_bound.has_value()); EXPECT_EQ(attrs.left_bound.value(), -1); ASSERT_TRUE(attrs.right_bound.has_value()); diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp index a6a872a5248d..7f27efb68f44 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp @@ -339,7 +339,6 @@ TEST_F(IntegrationSdpaFwdDescriptorLifting, SdpaFwdWithAllOptionalAttributesViaC .set_causal_mask(true) .set_causal_mask_bottom_right(true) .set_generate_stats(true) - .set_attn_scale(0.125f) .set_diagonal_band_left_bound(-1) .set_diagonal_band_right_bound(1) .set_paged_attention_max_seq_len_kv(256) @@ -438,8 +437,6 @@ TEST_F(IntegrationSdpaFwdDescriptorLifting, SdpaFwdWithAllOptionalAttributesViaC // Scalar values (direct member access) ASSERT_TRUE(attrs.dropout_probability.has_value()); EXPECT_FLOAT_EQ(attrs.dropout_probability.value(), 0.1f); - ASSERT_TRUE(attrs.attn_scale_value.has_value()); - EXPECT_FLOAT_EQ(attrs.attn_scale_value.value(), 0.125f); ASSERT_TRUE(attrs.left_bound.has_value()); EXPECT_EQ(attrs.left_bound.value(), -1); ASSERT_TRUE(attrs.right_bound.has_value()); From 98d245c8b0286ef7cf6399a1e9ead3eb73b529ab Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Tue, 4 Aug 2026 07:36:30 -0600 Subject: [PATCH 7/9] fix(hipdnn): hard-fail runtime pass-by-value invariant violations and fix scale-tensor uid collision A bundle whose runtime-pass-by-value tensor still carried a baked value or value_type was logged and silently skipped like any other malformed bundle, shrinking the suite without a red test anywhere. classifyBundle() now registers a synthetic failing test for that specific contradiction instead, and the check itself moves from applyTensorPatches into buildGraphBuffer so it covers every load path, not just the template-sweep path. The migration pipeline's smoke-test step used to collapse any non-zero exit into a single "may need GPU" warning, which would have masked this new hard failure too. It now greps loader output for "Failed to load bundle" to tell a real regression apart from a missing GPU. The SdpaFwdRuntimeScale bundle family is regenerated to move the runtime scale tensor off uid=4, which collided with the stats/descale UID slots. The generator drops its PyTorch/golden-blob dependency (these bundles synthesize inputs and reference-verify output at test time), adds causal/group/stats/fp8 variants, and gains a regenerate_bundles.sh script. README documents the tensor_patches mechanism these cases use. ALMIOPEN-2267 --- .../integration_test_bundles/README.md | 31 ++ .../bhsd/bf16/Small/Small.json | 147 ------- .../bhsd/bf16/Small/Small.meta.json | 12 - .../bf16/hd128_causal_batch/Small/Small.json | 6 +- .../hd128_causal_batch/Small/Small.meta.json | 9 +- .../bf16/hd128_causal_group/Small/Small.json | 30 +- .../hd128_causal_group/Small/Small.meta.json | 9 +- .../bf16/hd128_nomask_batch/Small/Small.json | 6 +- .../hd128_nomask_batch/Small/Small.meta.json | 9 +- .../SmallStats/SmallStats.json | 2 +- .../SmallStats/SmallStats.meta.json | 9 +- .../bf16/hd128_nomask_group/Small/Small.json | 30 +- .../hd128_nomask_group/Small/Small.meta.json | 9 +- .../bf16/hd192_causal_batch/Small/Small.json | 6 +- .../hd192_causal_batch/Small/Small.meta.json | 9 +- .../bf16/hd192_nomask_batch/Small/Small.json | 6 +- .../hd192_nomask_batch/Small/Small.meta.json | 9 +- .../fp16/hd128_causal_batch/Small/Small.json | 6 +- .../hd128_causal_batch/Small/Small.meta.json | 9 +- .../fp16/hd128_nomask_batch/Small/Small.json | 6 +- .../hd128_nomask_batch/Small/Small.meta.json | 9 +- .../SmallStats/SmallStats.json | 2 +- .../SmallStats/SmallStats.meta.json | 9 +- .../fp16/hd192_causal_batch/Small/Small.json | 6 +- .../hd192_causal_batch/Small/Small.meta.json | 9 +- .../fp16/hd192_nomask_batch/Small/Small.json | 6 +- .../hd192_nomask_batch/Small/Small.meta.json | 9 +- .../fp8/hd128_causal_batch/Small/Small.json | 2 +- .../hd128_causal_batch/Small/Small.meta.json | 7 +- .../fp8/hd128_causal_group/Small/Small.json | 2 +- .../hd128_causal_group/Small/Small.meta.json | 7 +- .../fp8/hd128_nomask_batch/Small/Small.json | 2 +- .../hd128_nomask_batch/Small/Small.meta.json | 7 +- .../SdpaFwdRuntimeScale/regenerate_bundles.sh | 108 +++++ .../migration-scripts/run_capture_pipeline.sh | 9 +- ...generate_sdpa_runtime_scale_test_bundle.py | 374 ++++++++++-------- .../src/harness/bundle/BundleRegistration.hpp | 148 +++++-- .../harness/bundle/IntegrationTestBundle.hpp | 71 +++- .../tests/TestBundleDiscovery.cpp | 184 +++++++++ 39 files changed, 856 insertions(+), 475 deletions(-) delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json delete mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json create mode 100644 dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/regenerate_bundles.sh diff --git a/dnn-providers/integration-tests/integration_test_bundles/README.md b/dnn-providers/integration-tests/integration_test_bundles/README.md index 048da0111c34..c827694f70ec 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/README.md +++ b/dnn-providers/integration-tests/integration_test_bundles/README.md @@ -124,6 +124,37 @@ Template-sweep segments: | `Operation` | PascalCase op name | `BatchnormFwdInference` | | `TopologyName` | Stable graph skeleton name | `Inference` | +### `tensor_patches` (per-case structural tensor edits) + +A `sweep.json` case can carry an optional `tensor_patches` array to make +structural edits to a tensor after `graph.template.json` placeholders are +expanded, but before the graph is sealed into a flatbuffer. This covers cases +that differ from the template by more than a placeholder substitution — e.g. a +case where a tensor is runtime-pass-by-value and must not also carry a baked +`value`/`value_type`. + +Each entry targets one tensor by `uid` and supports two operations: + +```json +"tensor_patches": [ + { + "uid": 4, + "set": { "is_runtime_pass_by_value": true }, + "remove": ["value", "value_type"] + } +] +``` + +- `set` (object): upserts the given fields on the target tensor. +- `remove` (array of strings): erases the given fields from the target tensor. +- `uid` must match a tensor present in the expanded graph, or loading the case + fails with an error. + +`set` is applied before `remove` for a given patch entry. A tensor marked +`is_runtime_pass_by_value: true` that still carries `value`/`value_type` after +patching fails validation at load time — use `remove` to drop the baked +fallback fields when converting a tensor to runtime pass-by-value. + ## Pull Data Locally Bundles are optional. Skip this step if you only need computed (GPU/CPU) diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json deleted file mode 100644 index 8418e98ee6e5..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "nodes": [ - { - "type": "SdpaAttributes", - "compute_data_type": "float", - "name": "", - "inputs": { - "q_tensor_uid": 0, - "k_tensor_uid": 1, - "v_tensor_uid": 2, - "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, - "seq_len_q_tensor_uid": null, - "seq_len_kv_tensor_uid": null, - "seed_tensor_uid": null, - "offset_tensor_uid": null, - "dropout_mask_tensor_uid": null, - "dropout_scale_tensor_uid": null, - "page_table_k_tensor_uid": null, - "page_table_v_tensor_uid": null, - "block_mask_tensor_uid": null, - "sink_token_tensor_uid": null, - "descale_q_tensor_uid": null, - "descale_k_tensor_uid": null, - "descale_v_tensor_uid": null, - "descale_s_tensor_uid": null, - "scale_s_tensor_uid": null, - "scale_o_tensor_uid": null - }, - "outputs": { - "o_tensor_uid": 3, - "stats_tensor_uid": null, - "max_tensor_uid": null, - "sum_exp_tensor_uid": null, - "rng_dump_tensor_uid": null, - "amax_s_tensor_uid": null, - "amax_o_tensor_uid": null - }, - "attributes": { - "generate_stats": null, - "alibi_mask": false, - "padding_mask": false, - "causal_mask": false, - "causal_mask_bottom_right": false, - "dropout_probability": null, - "attn_scale_value": null, - "left_bound": null, - "right_bound": null, - "max_seq_len_kv": null, - "diagonal_alignment": "TOP_LEFT", - "mma_core_mode": "float", - "implementation": "AUTO" - } - } - ], - "tensors": [ - { - "uid": 0, - "name": "Q", - "dims": [ - 2, - 4, - 256, - 128 - ], - "strides": [ - 131072, - 32768, - 128, - 1 - ], - "data_type": "bfloat16", - "virtual": false - }, - { - "uid": 1, - "name": "K", - "dims": [ - 2, - 4, - 256, - 128 - ], - "strides": [ - 131072, - 32768, - 128, - 1 - ], - "data_type": "bfloat16", - "virtual": false - }, - { - "uid": 2, - "name": "V", - "dims": [ - 2, - 4, - 256, - 128 - ], - "strides": [ - 131072, - 32768, - 128, - 1 - ], - "data_type": "bfloat16", - "virtual": false - }, - { - "uid": 3, - "name": "O", - "dims": [ - 2, - 4, - 256, - 128 - ], - "strides": [ - 131072, - 32768, - 128, - 1 - ], - "data_type": "bfloat16", - "virtual": false - }, - { - "uid": 4, - "name": "scale", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true - } - ], - "io_data_type": "bfloat16", - "compute_data_type": "float", - "intermediate_data_type": "float", - "name": "SdpaFwdRuntimeScale_bhsd_bf16_Small" -} \ No newline at end of file diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json deleted file mode 100644 index fc2fa174d641..000000000000 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small.meta.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "format_version": 1, - "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_test_bundle.py", - "generator_version": "1.1.0", - "generated_at": "2026-07-21T00:00:00Z", - "seed": 42, - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces output that diverges from the golden data.", - "inputs": { - "4": { "kind": "fixed", "value": 2.0 } - } -} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json index 871ea7b7fe14..1183bb9e3a54 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json index b194c2130d33..9c48a68d8eac 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:47Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json index a18f86d0dccc..30e2f565f95d 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": 5, "seq_len_kv_tensor_uid": 6, "seed_tensor_uid": null, @@ -126,19 +126,6 @@ "data_type": "bfloat16", "virtual": false }, - { - "uid": 4, - "name": "scale", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true - }, { "uid": 5, "name": "SeqLenQ", @@ -162,10 +149,23 @@ ], "data_type": "int32", "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_group_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json index b194c2130d33..9aa05042ce6d 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_causal_group/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:48Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json index ea77a88e85f6..8f02b60b13fe 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json index b194c2130d33..ea561a360b05 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:45Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json index 5e80ed767169..501921ecaf26 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -162,4 +162,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_stats_SmallStats" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json index b194c2130d33..96e63e71512a 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:46Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json index fe866b427c8e..20fb8e59837e 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": 5, "seq_len_kv_tensor_uid": 6, "seed_tensor_uid": null, @@ -126,19 +126,6 @@ "data_type": "bfloat16", "virtual": false }, - { - "uid": 4, - "name": "scale", - "dims": [ - 1 - ], - "strides": [ - 1 - ], - "data_type": "float", - "virtual": false, - "is_runtime_pass_by_value": true - }, { "uid": 5, "name": "SeqLenQ", @@ -162,10 +149,23 @@ ], "data_type": "int32", "virtual": false + }, + { + "uid": 10, + "name": "scale", + "dims": [ + 1 + ], + "strides": [ + 1 + ], + "data_type": "float", + "virtual": false, + "is_runtime_pass_by_value": true } ], "io_data_type": "bfloat16", "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_group_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json index b194c2130d33..96e63e71512a 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_group/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:46Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json index 51b7c9a2864e..6f025a2f4117 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd192_causal_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json index b194c2130d33..5baed47c433b 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_causal_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:49Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json index 0d9617f7c68b..bade4e1b5f79 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_bf16_hd192_nomask_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json index b194c2130d33..9aa05042ce6d 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/bf16/hd192_nomask_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:48Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json index d4b5716ff06d..c92168500b3b 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_causal_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json index b194c2130d33..5c5821936479 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_causal_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:50Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json index a2631964f9f5..7c258030a0c2 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json index b194c2130d33..5baed47c433b 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:49Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json index 27c54a2c55a6..cb797128beeb 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.json @@ -162,4 +162,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_stats_SmallStats" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json index b194c2130d33..5c5821936479 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd128_nomask_batch_stats/SmallStats/SmallStats.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:50Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json index 08bfdf7a3e63..e563109dbd15 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd192_causal_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json index b194c2130d33..a52f6ede9f66 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_causal_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:51Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json index 1f2c5c0dc3a0..3c78599b4301 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.json @@ -9,7 +9,7 @@ "k_tensor_uid": 1, "v_tensor_uid": 2, "attn_mask_tensor_uid": null, - "scale_tensor_uid": 4, + "scale_tensor_uid": 10, "seq_len_q_tensor_uid": null, "seq_len_kv_tensor_uid": null, "seed_tensor_uid": null, @@ -127,7 +127,7 @@ "virtual": false }, { - "uid": 4, + "uid": 10, "name": "scale", "dims": [ 1 @@ -144,4 +144,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp16_hd192_nomask_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json index b194c2130d33..a52f6ede9f66 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp16/hd192_nomask_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:51Z", "reference_source": "synthesis+cpu_reference", - "notes": "Pure-runtime scale bundle: scale (uid=4) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", + "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "4": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json index 26601875a885..08b2996236db 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.json @@ -180,4 +180,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json index b3061b9895cf..ddd440c60f56 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:52Z", "reference_source": "synthesis+cpu_reference", "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "10": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json index 475f3736e95a..39575a171652 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.json @@ -204,4 +204,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_group_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json index b3061b9895cf..1f3fea10b9b6 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_causal_group/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:53Z", "reference_source": "synthesis+cpu_reference", "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "10": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json index 1fb0569316d3..01e31b449766 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.json @@ -180,4 +180,4 @@ "compute_data_type": "float", "intermediate_data_type": "float", "name": "SdpaFwdRuntimeScale_bhsd_fp8_hd128_nomask_batch_Small" -} \ No newline at end of file +} diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json index b3061b9895cf..ddd440c60f56 100644 --- a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/bhsd/fp8/hd128_nomask_batch/Small/Small.meta.json @@ -3,10 +3,13 @@ "operation": "SdpaFwdRuntimeScale", "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": "1.0.0", - "generated_at": "2026-07-17T15:48:00Z", + "generated_at": "2026-07-31T21:51:52Z", "reference_source": "synthesis+cpu_reference", "notes": "Pure-runtime scale bundle: scale (uid=10) has is_runtime_pass_by_value=true with no baked value. The harness supplies the detection value (2.0) via the inputs field; both the CPU reference and the provider read it from the variantPack. A provider that ignores the runtime tensor and falls back to a hardcoded scale produces diverging output.", "inputs": { - "10": { "kind": "fixed", "value": 2.0 } + "10": { + "kind": "fixed", + "value": 2.0 + } } } diff --git a/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/regenerate_bundles.sh b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/regenerate_bundles.sh new file mode 100644 index 000000000000..47aac3a41eb2 --- /dev/null +++ b/dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale/regenerate_bundles.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +# SPDX-License-Identifier: MIT +# +# Regenerates all SdpaFwdRuntimeScale test bundles (quick tier). +# +# These bundles carry no tensor blobs (see generate_sdpa_runtime_scale_test_bundle.py): +# the harness synthesizes inputs and reference-verifies outputs at test time, so +# there is nothing here to pin to a DVC remote, unlike ../SdpaFwd/generate_golden_data.sh. +# +# Usage: +# cd /dnn-providers/integration-tests/integration_test_bundles/quick/SdpaFwdRuntimeScale +# bash regenerate_bundles.sh + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +GOLDEN_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +GENERATOR="$(cd "$GOLDEN_ROOT/../reference_data_scripts" && pwd)/generate_sdpa_runtime_scale_test_bundle.py" + +if [[ ! -f "$GENERATOR" ]]; then + echo "ERROR: Generator script not found at: $GENERATOR" + exit 1 +fi + +generate_bundle() { + local outdir="$1" + local name="$2" + shift 2 + mkdir -p "$outdir/$name" + python3 "$GENERATOR" --base-filename "$outdir/$name/$name" "$@" +} + +BHSD="$GOLDEN_ROOT/quick/SdpaFwdRuntimeScale/bhsd" + +echo "=== Generating SdpaFwdRuntimeScale quick tier ===" + +# --- bf16, hd128 --- +generate_bundle "$BHSD/bf16/hd128_nomask_batch" "Small" \ + --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_Small + +generate_bundle "$BHSD/bf16/hd128_nomask_group" "Small" \ + --variable-seq-lens --q-dims 3 4 512 128 --v-dims 3 4 512 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_group_Small + +generate_bundle "$BHSD/bf16/hd128_nomask_batch_stats" "SmallStats" \ + --stats --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_stats_SmallStats + +generate_bundle "$BHSD/bf16/hd128_causal_batch" "Small" \ + --causal bottom_right --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_batch_Small + +generate_bundle "$BHSD/bf16/hd128_causal_group" "Small" \ + --causal bottom_right --variable-seq-lens \ + --q-dims 3 4 512 128 --v-dims 3 4 512 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_group_Small + +# --- bf16, hd192 (D_qk=192, D_v=128) --- +generate_bundle "$BHSD/bf16/hd192_nomask_batch" "Small" \ + --q-dims 2 4 256 192 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd192_nomask_batch_Small + +generate_bundle "$BHSD/bf16/hd192_causal_batch" "Small" \ + --causal bottom_right --q-dims 2 4 256 192 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_bf16_hd192_causal_batch_Small + +# --- fp16, hd128 --- +generate_bundle "$BHSD/fp16/hd128_nomask_batch" "Small" \ + --dtype fp16 --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_Small + +generate_bundle "$BHSD/fp16/hd128_nomask_batch_stats" "SmallStats" \ + --dtype fp16 --stats --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp16_hd128_nomask_batch_stats_SmallStats + +generate_bundle "$BHSD/fp16/hd128_causal_batch" "Small" \ + --dtype fp16 --causal bottom_right --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp16_hd128_causal_batch_Small + +# --- fp16, hd192 (D_qk=192, D_v=128) --- +generate_bundle "$BHSD/fp16/hd192_nomask_batch" "Small" \ + --dtype fp16 --q-dims 2 4 256 192 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp16_hd192_nomask_batch_Small + +generate_bundle "$BHSD/fp16/hd192_causal_batch" "Small" \ + --dtype fp16 --causal bottom_right --q-dims 2 4 256 192 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp16_hd192_causal_batch_Small + +# --- fp8, hd128 --- +generate_bundle "$BHSD/fp8/hd128_nomask_batch" "Small" \ + --dtype fp8 --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp8_hd128_nomask_batch_Small + +generate_bundle "$BHSD/fp8/hd128_causal_batch" "Small" \ + --dtype fp8 --causal bottom_right --q-dims 2 4 256 128 --v-dims 2 4 256 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_batch_Small + +generate_bundle "$BHSD/fp8/hd128_causal_group" "Small" \ + --dtype fp8 --causal bottom_right --variable-seq-lens \ + --q-dims 3 4 512 128 --v-dims 3 4 512 128 \ + --name SdpaFwdRuntimeScale_bhsd_fp8_hd128_causal_group_Small + +echo "" +echo "=== Done ===" +echo "Generated bundles:" +find "$BHSD" -name "*.json" ! -name "*.meta.json" 2>/dev/null | sort diff --git a/dnn-providers/integration-tests/migration-scripts/run_capture_pipeline.sh b/dnn-providers/integration-tests/migration-scripts/run_capture_pipeline.sh index 7c38eff11539..19346d621a34 100755 --- a/dnn-providers/integration-tests/migration-scripts/run_capture_pipeline.sh +++ b/dnn-providers/integration-tests/migration-scripts/run_capture_pipeline.sh @@ -69,9 +69,14 @@ python3 "$SCRIPT_DIR/verify_migration.py" \ echo "" echo "--- Supporting: real binary smoke (bundle loader) ---" -"$BINARY" --allow-bundles --gd "$OUT" --gtest_filter="$BUNDLE_FILTER" || { +SMOKE_LOG="$WORK/smoke.log" +if ! "$BINARY" --allow-bundles --gd "$OUT" --gtest_filter="$BUNDLE_FILTER" 2>&1 | tee "$SMOKE_LOG"; then + if grep -q "Failed to load bundle" "$SMOKE_LOG"; then + echo " FAIL: a bundle failed to load — this is a real regression, not a missing-GPU skip" >&2 + exit 1 + fi echo " WARN: smoke returned non-zero (may need GPU)" >&2 -} +fi # ── Supporting layer: idempotency ─────────────────────────────────────── diff --git a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py index 105965e8b0a1..b842fd290f0b 100644 --- a/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py +++ b/dnn-providers/integration-tests/reference_data_scripts/generate_sdpa_runtime_scale_test_bundle.py @@ -2,56 +2,75 @@ # Copyright © Advanced Micro Devices, Inc., or its affiliates. # SPDX-License-Identifier: MIT """ -SDPA Forward Runtime Scale Golden Reference Bundle Generator +SDPA Forward Runtime Scale Test Bundle Generator -Generates pre-computed reference data for SDPA forward where the attention -scale is provided as a runtime pass-by-value tensor (dims=[1], strides=[1], -uid=4) rather than a compile-time baked scalar (attn_scale_value attribute). +Generates graph-only reference bundles for SDPA forward where the attention +scale is provided as a runtime pass-by-value tensor (dims=[1], strides=[1]) +rather than a compile-time baked scalar (attn_scale_value attribute). In existing SDPA bundles the scale is baked into the node's `attn_scale_value` attribute. This script instead wires it as a runtime tensor via `scale_tensor_uid`, leaving `attn_scale_value` as null. A provider that ignores the runtime scale and falls back to a compile-time default will produce detectably wrong output. -Uses PyTorch's SDPBackend.MATH as the golden reference source. -Supports BF16 and FP16 data types. +These bundles carry no tensor blobs: the harness synthesizes Q/K/V/etc. itself +and verifies provider output against its own CPU reference executor. The only +thing this generator needs to communicate beyond the graph shape is which +runtime tensor should be pinned to a fixed detection value — done via the +`inputs` field in the companion `.meta.json`. There is no golden data to +compute, so this script has no numeric/tensor-framework dependency. -Output: {base_filename}.json + {base_filename}.tensor{uid}.bin + {base_filename}.meta.json +Tensor UID slots (fixed convention across this bundle family): + 0=Q 1=K 2=V 3=O 4=stats(LSE, if --stats) 5=SeqLenQ 6=SeqLenKv (if + --variable-seq-lens) 7/8/9=DescaleQ/K/V (if --dtype fp8) 10=scale (always + — the scale tensor's UID is never referenced positionally, only via the + node's explicit scale_tensor_uid field, so a single fixed slot above the + highest optional-tensor slot avoids any collision regardless of flags). + +Output: {base_filename}.json + {base_filename}.meta.json Usage: - python generate_sdpa_runtime_scale_golden.py \\ - --base-filename bundles/SdpaFwdRuntimeScale/bhsd/bf16/Small/Small \\ + python generate_sdpa_runtime_scale_test_bundle.py \\ + --base-filename bundles/SdpaFwdRuntimeScale/bhsd/bf16/hd128_nomask_batch/Small \\ --q-dims 2 4 256 128 --v-dims 2 4 256 128 \\ - --scale-value 1.0 --dtype bf16 --seed 42 + --name SdpaFwdRuntimeScale_bhsd_bf16_hd128_nomask_batch_Small """ import argparse import datetime -import hashlib import json -import math import os import sys -import torch -import torch.nn.functional as F -from torch.nn.attention import SDPBackend, sdpa_kernel - # Bump when generator logic changes in a way that affects output data. -# 1.0.0 — Initial: SDPA forward with runtime scale tensor (uid=4) +# 1.0.0 — Initial: SDPA forward with runtime scale tensor (dynamic UID: 4 +# normally, displaced to 10 when stats or fp8 also claim slot 4/7-9), +# with --causal (bottom_right), --variable-seq-lens (group/ragged +# batch), --stats (LSE), and --dtype fp8 (+ descale) support. Carries +# no tensor blobs and no PyTorch dependency: this bundle family's +# inputs are synthesized and outputs are reference-verified by the +# harness at test time, so there is no golden data for this script to +# compute. GENERATOR_VERSION = "1.0.0" -DTYPE_MAP = { - "bf16": {"torch": torch.bfloat16, "json": "bfloat16", "bytes": 2}, - "fp16": {"torch": torch.float16, "json": "half", "bytes": 2}, +DTYPE_JSON = { + "bf16": "bfloat16", + "fp16": "half", + "fp8": "fp8_e4m3", } -# UID assignments +# Tensor UID assignment (stable contract with the JSON consumer / loader). UID_Q = 0 UID_K = 1 UID_V = 2 UID_O = 3 -UID_SCALE = 4 # runtime scalar tensor — dims=[1], strides=[1] +UID_STATS = 4 +UID_SEQ_LEN_Q = 5 +UID_SEQ_LEN_KV = 6 +UID_DESCALE_Q = 7 +UID_DESCALE_K = 8 +UID_DESCALE_V = 9 +UID_SCALE = 10 def compute_contiguous_strides(dims): @@ -64,46 +83,33 @@ def compute_contiguous_strides(dims): return strides -def compute_forward(Q, K, V, scale, H_q, H_kv): - """SDPA forward via PyTorch Math backend.""" - with sdpa_kernel(SDPBackend.MATH): - O = F.scaled_dot_product_attention( - Q, - K, - V, - scale=scale, - enable_gqa=(H_q != H_kv), - ) - return O - - -def save_tensor_bin(tensor, path): - t = tensor.contiguous().cpu() - if t.dtype in (torch.bfloat16, torch.float16): - raw = t.view(torch.uint8).numpy().tobytes() - else: - raw = t.numpy().tobytes() - with open(path, "wb") as f: - f.write(raw) - - -def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): +def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype, causal, group, stats, name): """Build the SDPA graph JSON with scale wired as a runtime tensor. Key difference from the compile-time variant (generate_sdpa_fwd_golden.py): - - scale_tensor_uid = UID_SCALE (pure runtime PBV tensor, no baked fallback) - - attn_scale_value = null (forces CPU reference to read from variantPack) + - scale_tensor_uid points at the runtime scale tensor (no baked fallback) + - attn_scale_value = null (forces the CPU reference to read from variantPack) A provider that falls back to a compile-time default (e.g. 1/sqrt(headDim)) instead of reading the runtime tensor produces output that diverges from the CPU reference. """ + B = q_dims[0] + is_fp8 = dtype == "fp8" + qkv_json_dtype = DTYPE_JSON[dtype] + # fp8 attention output is bf16; io_data_type mirrors that (matches the + # committed fp8 bundles, even though Q/K/V are individually fp8_e4m3). + o_json_dtype = "bfloat16" if is_fp8 else qkv_json_dtype + io_json_dtype = o_json_dtype + + scale_uid = UID_SCALE + tensors = [ { "uid": UID_Q, "name": "Q", "dims": q_dims, "strides": compute_contiguous_strides(q_dims), - "data_type": dtype_str, + "data_type": qkv_json_dtype, "virtual": False, }, { @@ -111,7 +117,7 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "name": "K", "dims": k_dims, "strides": compute_contiguous_strides(k_dims), - "data_type": dtype_str, + "data_type": qkv_json_dtype, "virtual": False, }, { @@ -119,7 +125,7 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "name": "V", "dims": v_dims, "strides": compute_contiguous_strides(v_dims), - "data_type": dtype_str, + "data_type": qkv_json_dtype, "virtual": False, }, { @@ -127,19 +133,80 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "name": "O", "dims": o_dims, "strides": compute_contiguous_strides(o_dims), - "data_type": dtype_str, + "data_type": o_json_dtype, "virtual": False, }, + ] + + stats_tensor_uid = None + if stats: + lse_dims = [B, q_dims[1], q_dims[2], 1] + tensors.append( + { + "uid": UID_STATS, + "name": "LSE", + "dims": lse_dims, + "strides": compute_contiguous_strides(lse_dims), + "data_type": "float", + "virtual": False, + } + ) + stats_tensor_uid = UID_STATS + + seq_len_q_tensor_uid = None + seq_len_kv_tensor_uid = None + if group: + for uid, tname in [(UID_SEQ_LEN_Q, "SeqLenQ"), (UID_SEQ_LEN_KV, "SeqLenKv")]: + tensors.append( + { + "uid": uid, + "name": tname, + "dims": [B + 1], + "strides": [1], + "data_type": "int32", + "virtual": False, + } + ) + seq_len_q_tensor_uid = UID_SEQ_LEN_Q + seq_len_kv_tensor_uid = UID_SEQ_LEN_KV + + descale_q_tensor_uid = descale_k_tensor_uid = descale_v_tensor_uid = None + if is_fp8: + for uid, tname in [ + (UID_DESCALE_Q, "DescaleQ"), + (UID_DESCALE_K, "DescaleK"), + (UID_DESCALE_V, "DescaleV"), + ]: + tensors.append( + { + "uid": uid, + "name": tname, + "dims": [1], + "strides": [1], + "data_type": "float", + "virtual": False, + } + ) + descale_q_tensor_uid = UID_DESCALE_Q + descale_k_tensor_uid = UID_DESCALE_K + descale_v_tensor_uid = UID_DESCALE_V + + tensors.append( { - "uid": UID_SCALE, + "uid": scale_uid, "name": "scale", "dims": [1], "strides": [1], "data_type": "float", "virtual": False, "is_runtime_pass_by_value": True, - }, - ] + } + ) + + causal_mask_bottom_right = causal == "bottom_right" + diagonal_alignment = "BOTTOM_RIGHT" if causal_mask_bottom_right else "TOP_LEFT" + left_bound = -1 if causal_mask_bottom_right else None + right_bound = 0 if causal_mask_bottom_right else None graph = { "nodes": [ @@ -152,9 +219,9 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "k_tensor_uid": UID_K, "v_tensor_uid": UID_V, "attn_mask_tensor_uid": None, - "scale_tensor_uid": UID_SCALE, # runtime tensor - "seq_len_q_tensor_uid": None, - "seq_len_kv_tensor_uid": None, + "scale_tensor_uid": scale_uid, # runtime tensor + "seq_len_q_tensor_uid": seq_len_q_tensor_uid, + "seq_len_kv_tensor_uid": seq_len_kv_tensor_uid, "seed_tensor_uid": None, "offset_tensor_uid": None, "dropout_mask_tensor_uid": None, @@ -163,16 +230,16 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "page_table_v_tensor_uid": None, "block_mask_tensor_uid": None, "sink_token_tensor_uid": None, - "descale_q_tensor_uid": None, - "descale_k_tensor_uid": None, - "descale_v_tensor_uid": None, + "descale_q_tensor_uid": descale_q_tensor_uid, + "descale_k_tensor_uid": descale_k_tensor_uid, + "descale_v_tensor_uid": descale_v_tensor_uid, "descale_s_tensor_uid": None, "scale_s_tensor_uid": None, "scale_o_tensor_uid": None, }, "outputs": { "o_tensor_uid": UID_O, - "stats_tensor_uid": None, + "stats_tensor_uid": stats_tensor_uid, "max_tensor_uid": None, "sum_exp_tensor_uid": None, "rng_dump_tensor_uid": None, @@ -180,70 +247,50 @@ def build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_str): "amax_o_tensor_uid": None, }, "attributes": { - "generate_stats": None, + "generate_stats": True if stats else None, "alibi_mask": False, "padding_mask": False, "causal_mask": False, - "causal_mask_bottom_right": False, + "causal_mask_bottom_right": causal_mask_bottom_right, "dropout_probability": None, "attn_scale_value": None, # null — scale is runtime, not baked - "left_bound": None, - "right_bound": None, + "left_bound": left_bound, + "right_bound": right_bound, "max_seq_len_kv": None, - "diagonal_alignment": "TOP_LEFT", + "diagonal_alignment": diagonal_alignment, "mma_core_mode": "float", "implementation": "AUTO", }, } ], "tensors": tensors, - "io_data_type": dtype_str, + "io_data_type": io_json_dtype, "compute_data_type": "float", "intermediate_data_type": "float", - "name": "", + "name": name, } - return graph + return graph, scale_uid -def _get_generator_sha256(): - script_path = os.path.abspath(__file__) - with open(script_path, "rb") as f: - return hashlib.sha256(f.read()).hexdigest() - - -def build_meta_json(config, pytorch_version): - rocm_ver = "" - if "+rocm" in pytorch_version: - rocm_ver = pytorch_version.split("+rocm")[1] - +def build_meta_json(scale_uid, scale_value): return { "format_version": 1, "operation": "SdpaFwdRuntimeScale", - "generator": "generate_sdpa_runtime_scale_golden.py", - "generator_sha256": _get_generator_sha256(), + "generator": "generate_sdpa_runtime_scale_test_bundle.py", "generator_version": GENERATOR_VERSION, "generated_at": datetime.datetime.now(datetime.timezone.utc).strftime( "%Y-%m-%dT%H:%M:%SZ" ), - "reference_source": f"PyTorch {pytorch_version}", - "reference_backend": "pytorch_math_backend", - "rocm_version": rocm_ver, - "seed": config["seed"], + "reference_source": "synthesis+cpu_reference", "notes": ( - f"Runtime scale bundle: scale (uid={UID_SCALE}) is a runtime tensor " - "(no value_type/value field in JSON; attn_scale_value attribute is null). " - f"Detection value={config['scale_value']} is intentionally far from the " - "compile-time default (1/sqrt(D_qk)) to expose providers that use a " - "baked-in compile-time scale instead of the runtime tensor." + f"Pure-runtime scale bundle: scale (uid={scale_uid}) has " + "is_runtime_pass_by_value=true with no baked value. The harness " + f"supplies the detection value ({scale_value}) via the inputs " + "field; both the CPU reference and the provider read it from the " + "variantPack. A provider that ignores the runtime tensor and " + "falls back to a hardcoded scale produces diverging output." ), - "config": { - "q_dims": config["q_dims"], - "v_dims": config["v_dims"], - "dtype": config["dtype"], - "scale_uid": UID_SCALE, - "scale_value": config["scale_value"], - "gqa_ratio": config["q_dims"][1] // config["v_dims"][1], - }, + "inputs": {str(scale_uid): {"kind": "fixed", "value": scale_value}}, } @@ -252,14 +299,21 @@ def generate_bundle( q_dims, v_dims, dtype="bf16", - scale_value=1.0, - seed=42, - min_val=-1.0, - max_val=1.0, + causal="none", + group=False, + stats=False, + scale_value=2.0, + name="", ): - if dtype not in DTYPE_MAP: + if dtype not in DTYPE_JSON: print( - f"ERROR: --dtype must be one of {list(DTYPE_MAP.keys())} (got '{dtype}')", + f"ERROR: --dtype must be one of {list(DTYPE_JSON.keys())} (got '{dtype}')", + file=sys.stderr, + ) + sys.exit(1) + if causal not in ("none", "bottom_right"): + print( + f"ERROR: --causal must be one of ('none', 'bottom_right') (got '{causal}')", file=sys.stderr, ) sys.exit(1) @@ -274,76 +328,29 @@ def generate_bundle( errors.append(f"Batch mismatch: Q batch={B}, V batch={B_v}") if H_q % H_kv != 0: errors.append(f"H_q ({H_q}) must be divisible by H_kv ({H_kv})") - if min_val >= max_val: - errors.append(f"--min ({min_val}) must be less than --max ({max_val})") if errors: for e in errors: print(f"ERROR: {e}", file=sys.stderr) sys.exit(1) - dtype_info = DTYPE_MAP[dtype] - torch_dtype = dtype_info["torch"] - os.makedirs(os.path.dirname(os.path.abspath(base_filename)), exist_ok=True) - compile_time_default = 1.0 / math.sqrt(D_qk) print(f"Generating SDPA runtime scale bundle: {base_filename}") print(f" Q: {q_dims}, K: {k_dims}, V: {v_dims}, O: {o_dims}") - print(f" dtype: {dtype}, seed: {seed}") - print( - f" scale uid={UID_SCALE}, runtime value={scale_value} " - f"(compile-time default would be {compile_time_default:.6f})" - ) - - rng = torch.Generator().manual_seed(seed) - Q = torch.empty(q_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) - K = torch.empty(k_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) - V = torch.empty(v_dims, dtype=torch_dtype).uniform_(min_val, max_val, generator=rng) - scale_tensor = torch.full([1], scale_value, dtype=torch.float32) + print(f" dtype: {dtype}, causal: {causal}, group: {group}, stats: {stats}") - try: - O = compute_forward(Q, K, V, scale_value, H_q, H_kv) - except RuntimeError as e: - print(f"ERROR: PyTorch SDPA failed: {e}", file=sys.stderr) - sys.exit(1) - - for name, t in [("Q", Q), ("K", K), ("V", V), ("O", O)]: - assert not torch.isnan(t).any(), f"NaN in {name}" - assert not torch.isinf(t).any(), f"Inf in {name}" - - # Write tensor .bin files - tensor_list = [ - ("Q", Q, UID_Q), - ("K", K, UID_K), - ("V", V, UID_V), - ("O", O, UID_O), - ("scale", scale_tensor, UID_SCALE), - ] - for name, tensor, uid in tensor_list: - bin_path = f"{base_filename}.tensor{uid}.bin" - save_tensor_bin(tensor, bin_path) - size_bytes = os.path.getsize(bin_path) - print( - f" {name} (uid={uid}): {list(tensor.shape)} {tensor.dtype} -> {size_bytes} bytes" - ) + graph_json, scale_uid = build_graph_json( + q_dims, k_dims, v_dims, o_dims, dtype, causal, group, stats, name + ) + print(f" scale uid={scale_uid}, detection value={scale_value}") - # Write graph JSON - graph_json = build_graph_json(q_dims, k_dims, v_dims, o_dims, dtype_info["json"]) json_path = f"{base_filename}.json" with open(json_path, "w") as f: json.dump(graph_json, f, indent=4) f.write("\n") print(f" Graph JSON: {json_path}") - # Write meta JSON - config = { - "q_dims": q_dims, - "v_dims": v_dims, - "dtype": dtype, - "scale_value": scale_value, - "seed": seed, - } - meta_json = build_meta_json(config, torch.__version__) + meta_json = build_meta_json(scale_uid, scale_value) meta_path = f"{base_filename}.meta.json" with open(meta_path, "w") as f: json.dump(meta_json, f, indent=4) @@ -353,7 +360,7 @@ def generate_bundle( def main(): parser = argparse.ArgumentParser( - description="Generate SDPA forward runtime scale golden reference bundles" + description="Generate SDPA forward runtime scale test bundles (graph + meta only)" ) parser.add_argument( "--base-filename", @@ -379,22 +386,44 @@ def main(): parser.add_argument( "--dtype", default="bf16", - choices=list(DTYPE_MAP.keys()), - help="Input/output tensor dtype (default: bf16)", + choices=list(DTYPE_JSON.keys()), + help="Q/K/V tensor dtype (default: bf16). 'fp8' emits fp8_e4m3 " + "Q/K/V with a bf16 output and per-tensor descale_q/k/v runtime tensors.", + ) + parser.add_argument( + "--causal", + default="none", + choices=["none", "bottom_right"], + help="Causal masking mode (default: none).", + ) + parser.add_argument( + "--variable-seq-lens", + action="store_true", + help="Declare runtime seq_len_q/seq_len_kv tensors (uid 5/6) for a " + "ragged/padded batch, in addition to Q/K/V/O.", + ) + parser.add_argument( + "--stats", + action="store_true", + help="Declare a runtime stats (LSE) output tensor (uid=4).", ) parser.add_argument( "--scale-value", type=float, - default=1.0, + default=2.0, help=( - "Detection value for the runtime scale tensor (uid=4). " - "Default=1.0 (no scaling) is far from the typical compile-time " - "default of 1/sqrt(D_qk) to enable detection of incorrect handling." + "Detection value for the runtime scale tensor, recorded in " + "meta.json's 'inputs' field for the harness to inject. Default=2.0 " + "is far from the typical compile-time default of 1/sqrt(D_qk) to " + "enable detection of incorrect handling." ), ) - parser.add_argument("--seed", type=int, default=42) - parser.add_argument("--min", type=float, default=-1.0, dest="min_val") - parser.add_argument("--max", type=float, default=1.0, dest="max_val") + parser.add_argument( + "--name", + required=True, + help="Graph-level 'name' field, e.g. " + "SdpaFwdRuntimeScale_bhsd_bf16_hd128_causal_batch_Small", + ) args = parser.parse_args() generate_bundle( @@ -402,10 +431,11 @@ def main(): q_dims=args.q_dims, v_dims=args.v_dims, dtype=args.dtype, + causal=args.causal, + group=args.variable_seq_lens, + stats=args.stats, scale_value=args.scale_value, - seed=args.seed, - min_val=args.min_val, - max_val=args.max_val, + name=args.name, ) print("\nDone.") diff --git a/dnn-providers/integration-tests/src/harness/bundle/BundleRegistration.hpp b/dnn-providers/integration-tests/src/harness/bundle/BundleRegistration.hpp index a69458de67e4..98b78fcf9df8 100644 --- a/dnn-providers/integration-tests/src/harness/bundle/BundleRegistration.hpp +++ b/dnn-providers/integration-tests/src/harness/bundle/BundleRegistration.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,112 @@ struct LoadedBundle std::shared_ptr bundle; }; +// A GTest test body that immediately fails with a stored diagnostic message. +// Registered in place of a bundle that failed to load, so the failure surfaces +// as a red test result — attributed to that bundle's suite/test name — instead +// of only an ERROR log line that nothing in CI asserts on. +// +// TestBody() is public (rather than the usual protected/private override) so +// tests can invoke it directly to verify the failure message it records; +// GTest's own dispatch through Test::Run() works the same regardless of +// access, since that call happens from within the base class. +class FailedBundleLoadTest : public ::testing::Test +{ +public: + explicit FailedBundleLoadTest(std::string message) + : _message(std::move(message)) + { + } + + void TestBody() override + { + ADD_FAILURE() << _message; + } + +private: + std::string _message; +}; + +// Registers a synthetic failing test for a bundle that failed to load. Keeps +// registration of the other, unrelated bundles unaffected: this only replaces +// what would otherwise be a silently-dropped test with a failing one under the +// same suite/test name. +inline void registerFailedBundleLoad(const std::string& suiteName, + const std::string& testName, + const std::string& message) +{ + ::testing::RegisterTest( + suiteName.c_str(), + testName.c_str(), + nullptr, + nullptr, + __FILE__, + __LINE__, + [message]() -> ::testing::Test* { return new FailedBundleLoadTest(message); }); +} + +// A bundle that failed to load, carrying enough information to register a +// FailedBundleLoadTest in its place: the suite/test name it would have used +// had it loaded, plus a diagnostic message describing why it didn't. +struct FailedLoad +{ + std::string suiteName; + std::string testName; + std::string message; +}; + +// A bundle that failed to load for an ordinary reason (malformed JSON, missing +// metadata, a bad sweep case, ...). No test is registered for it — only the +// diagnostic message to log. Kept distinct from FailedLoad so only the +// RuntimePassByValueInvariantError contradiction (see IntegrationTestBundle.hpp) +// turns the suite red; every other load failure keeps the original +// log-and-skip behavior. +struct SkippedLoad +{ + std::string message; +}; + +// The result of attempting to load one discovered bundle: it loaded +// successfully, it hit the PBV invariant and should hard-fail, or it failed to +// load for some other reason and should be skipped quietly. +using LoadOutcome = std::variant; + +// Attempts to load one discovered bundle and classifies the outcome. Split out +// from registerBundleTests() so the decision (did this bundle load, and if +// not, why) is a pure function that can be unit tested without touching +// ::testing::RegisterTest, which is only valid to call before RUN_ALL_TESTS() +// runs and so can't be exercised from within a running test body. +inline LoadOutcome classifyBundle(const DiscoveredBundle& disc) +{ + const auto diagnosticPath = disc.diagnosticPath(); + LoadResult loadResult; + try + { + loadResult = loadIntegrationTestBundle(disc); + } + catch(const RuntimePassByValueInvariantError& e) + { + return FailedLoad{disc.suiteName, + disc.testName, + "Failed to load bundle " + diagnosticPath.string() + ": " + e.what()}; + } + catch(const std::exception& e) + { + return SkippedLoad{"Skipping bundle " + diagnosticPath.string() + ": " + e.what()}; + } + + if(const auto* error = std::get_if(&loadResult)) + { + return SkippedLoad{"Skipping bundle " + diagnosticPath.string() + ": " + toString(*error)}; + } + + return LoadedBundle{diagnosticPath, + disc.suiteName, + disc.testName, + std::make_shared( + std::move(std::get(loadResult)))}; +} + // Registers one GTest test per preloaded bundle, run by the Engine executor. // This is the runtime, macro-free equivalent of TEST_F + INSTANTIATE_TEST_SUITE_P: // the suite/test names come from the filesystem scan, so they cannot be baked in @@ -116,40 +223,35 @@ inline void registerBundleTests() return; } - // Load all bundles eagerly, once, at registration time. A bundle that cannot - // be loaded (malformed JSON, invalid graph, or missing/invalid metadata) is - // logged and skipped — no test is registered for it. A bundle whose .bin - // blobs are absent loads with tensors == nullopt; its test registers and the - // harness SKIPs it at run time. A wrong-size blob throws here and is treated - // the same as any other load failure (logged and skipped). + // Load all bundles eagerly, once, at registration time. A bundle that + // fails to load because of the runtime-pass-by-value invariant (see + // RuntimePassByValueInvariantError in IntegrationTestBundle.hpp) gets a + // synthetic failing test registered in its place — see + // detail::registerFailedBundleLoad() — instead of just an ERROR log, so + // that specific contradiction turns the suite red rather than quietly + // shrinking it. Every other load failure (malformed JSON, invalid graph, + // missing/invalid metadata, a bad sweep case, a wrong-size blob) keeps the + // original behavior: logged and skipped, no test registered. A bundle + // whose .bin blobs are absent loads with tensors == nullopt; its test + // registers normally and the harness SKIPs it at run time. std::vector bundles; bundles.reserve(discovered.size()); for(const auto& disc : discovered) { - const auto diagnosticPath = disc.diagnosticPath(); - LoadResult loadResult; - try + auto outcome = detail::classifyBundle(disc); + if(auto* failed = std::get_if(&outcome)) { - loadResult = loadIntegrationTestBundle(disc); - } - catch(const std::exception& e) - { - HIPDNN_PLUGIN_LOG_ERROR("Skipping bundle " << diagnosticPath << ": " << e.what()); + HIPDNN_PLUGIN_LOG_ERROR(failed->message); + detail::registerFailedBundleLoad(failed->suiteName, failed->testName, failed->message); continue; } - - if(const auto* error = std::get_if(&loadResult)) + if(auto* skipped = std::get_if(&outcome)) { - HIPDNN_PLUGIN_LOG_ERROR("Skipping bundle " << diagnosticPath << ": " - << toString(*error)); + HIPDNN_PLUGIN_LOG_ERROR(skipped->message); continue; } - bundles.push_back({diagnosticPath, - disc.suiteName, - disc.testName, - std::make_shared( - std::move(std::get(loadResult)))}); + bundles.push_back(std::move(std::get(outcome))); } if(bundles.empty()) diff --git a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp index 6739d2c72340..f8e5be8c3bde 100644 --- a/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp +++ b/dnn-providers/integration-tests/src/harness/bundle/IntegrationTestBundle.hpp @@ -217,9 +217,53 @@ inline std::optional parseJsonFile(const std::filesystem::path& return std::make_optional(std::move(json)); } +// Thrown only by validateRuntimePassByValueTensors(), distinct from the generic +// schema-conversion failures buildGraphBuffer() otherwise collapses to +// LoadError::INVALID_GRAPH_SCHEMA. Kept as its own type so callers can single +// this one contradiction out for a hard failure instead of a quiet skip — see +// BundleRegistration.hpp's classifyBundle(). +class RuntimePassByValueInvariantError : public std::runtime_error +{ +public: + using std::runtime_error::runtime_error; +}; + +// Invariant: a tensor with is_runtime_pass_by_value=true must not also carry a baked +// value_type or value — if it does, both the CPU reference and the provider silently +// short-circuit to the baked value and the runtime path is never exercised. Checked here +// rather than in applyTensorPatches so it covers every path that reaches a graph buffer, +// not just the template-sweep path that patches tensors. +inline void validateRuntimePassByValueTensors(const nlohmann::json& graphJson) +{ + if(!graphJson.contains("tensors") || !graphJson.at("tensors").is_array()) + { + return; + } + + for(const auto& tensor : graphJson.at("tensors")) + { + if(tensor.value("is_runtime_pass_by_value", false) + && (tensor.contains("value_type") || tensor.contains("value"))) + { + const auto uid = tensor.value("uid", int64_t{-1}); + throw RuntimePassByValueInvariantError( + "tensor uid " + std::to_string(uid) + + " has is_runtime_pass_by_value=true but still carries value_type or value;" + " remove them from the tensor JSON, or from the sweep case's tensor_patches" + " 'remove' list or template"); + } + } +} + +// Validates the PBV invariant outside the try block below so its distinct +// RuntimePassByValueInvariantError propagates to the caller uncaught, instead +// of being collapsed into the generic false/INVALID_GRAPH_SCHEMA result used +// for ordinary schema-conversion failures. inline bool buildGraphBuffer(const nlohmann::json& graphJson, flatbuffers::DetachedBuffer& graphBuffer) { + validateRuntimePassByValueTensors(graphJson); + flatbuffers::FlatBufferBuilder builder; try { @@ -620,22 +664,6 @@ inline void applyTensorPatches(nlohmann::json& expandedGraph, const nlohmann::js + " not found in expanded graph"); } } - - // Invariant: a tensor with is_runtime_pass_by_value=true must not also carry a baked - // value_type or value — if it does, both the CPU reference and the provider silently - // short-circuit to the baked value and the runtime path is never exercised. - for(const auto& tensor : expandedGraph.at("tensors")) - { - if(tensor.value("is_runtime_pass_by_value", false) - && (tensor.contains("value_type") || tensor.contains("value"))) - { - const auto uid = tensor.value("uid", int64_t{-1}); - throw std::runtime_error( - "tensor uid " + std::to_string(uid) - + " has is_runtime_pass_by_value=true but still carries value_type or value;" - " remove them from the tensor_patches 'remove' list or the template"); - } - } } inline const nlohmann::json* findSweepCase(const nlohmann::json& sweepJson, @@ -696,8 +724,12 @@ inline std::optional // * inputs and outputs present -> bundle verified against golden data // // Inputs and outputs are loaded independently. Output uids come from the graph; -// every other declared tensor is treated as input. The function is total: it -// never lets an exception escape. +// every other declared tensor is treated as input. Every failure above is +// reported through the return value, except one: a +// RuntimePassByValueInvariantError from buildGraphBuffer() propagates +// uncaught, since callers (see BundleRegistration.hpp's classifyBundle()) +// deliberately treat that one contradiction as a hard failure rather than a +// quiet skip. inline LoadResult loadIntegrationTestBundle(const std::filesystem::path& jsonPath) { const auto graphJson = detail::parseJsonFile(jsonPath); @@ -760,6 +792,9 @@ inline LoadResult loadIntegrationTestBundle(const std::filesystem::path& jsonPat // case id, expand `${case...}` placeholders, load inline metadata, and resolve an // optional golden directory. Sweep authoring errors are reported as // INVALID_SWEEP_CASE; an expanded graph that still fails schema conversion is +// INVALID_GRAPH_SCHEMA. As with the direct-bundle overload, a +// RuntimePassByValueInvariantError from buildGraphBuffer() is the one +// exception that propagates uncaught rather than being folded into // INVALID_GRAPH_SCHEMA. inline LoadResult loadIntegrationTestBundle(const DiscoveredBundle& discovered) { diff --git a/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp b/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp index b6e5ab3afd59..a1a2487fd91f 100644 --- a/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp +++ b/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp @@ -1,6 +1,7 @@ // Copyright © Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT +#include #include #include @@ -16,6 +17,7 @@ #include #include "harness/bundle/BundleDiscovery.hpp" +#include "harness/bundle/BundleRegistration.hpp" #include "harness/bundle/IntegrationTestBundle.hpp" using namespace hipdnn_integration_tests::bundle; @@ -608,6 +610,55 @@ TEST_F(TestBundleDiscoveryFixture, LoadTemplateSweepCaseMissingTensorValueIsErro EXPECT_EQ(std::get(result), LoadError::INVALID_SWEEP_CASE); } +// A tensor_patches "set" that flips is_runtime_pass_by_value to true while the +// tensor still carries a baked value_type/value is rejected: buildGraphBuffer's +// validateRuntimePassByValueTensors check runs on the expanded+patched graph, so +// the contradiction can't slip through the template-sweep path. It throws +// RuntimePassByValueInvariantError rather than returning INVALID_GRAPH_SCHEMA, +// so this one contradiction can be routed to a hard failure (see +// classifyBundle() in BundleRegistration.hpp) instead of the quiet skip every +// other load failure gets. +TEST_F(TestBundleDiscoveryFixture, LoadTemplateSweepCaseWithBakedValueAndRuntimePassByValueIsError) +{ + const auto sweepDir = _tempDir / "quick" / "BatchnormFwdInference" / "Inference"; + createTemplateSweep(sweepDir, + {{"baked_runtime_scale_fp32_nchw", + "float", + {2, 3, 4, 5}, + {60, 20, 5, 1}, + {1, 3, 1, 1}, + {3, 1, 1, 1}}}); + + auto sweepJson = nlohmann::json::parse(std::ifstream(sweepDir / "sweep.json")); + sweepJson["cases"][0]["tensor_patches"] = nlohmann::json::array( + {{{"uid", 3}, + {"set", + {{"is_runtime_pass_by_value", true}, {"value_type", "Float32Value"}, {"value", 2.0}}}}}); + std::ofstream(sweepDir / "sweep.json") << sweepJson.dump(2); + + const auto discovered = discoverBundles(_tempDir); + ASSERT_EQ(discovered.size(), 1u); + + EXPECT_THROW(loadIntegrationTestBundle(discovered.front()), + detail::RuntimePassByValueInvariantError); +} + +// The same invariant must hold for a direct (non-sweep) bundle's graph.json, +// which never goes through applyTensorPatches. Regression test for the gap +// where validateRuntimePassByValueTensors lived only in applyTensorPatches and +// this path loaded a contradictory tensor without complaint. +TEST_F(TestBundleDiscoveryFixture, LoadDirectBundleWithBakedValueAndRuntimePassByValueIsError) +{ + auto dir = _tempDir / "op" / "bakedscale"; + std::filesystem::create_directories(dir); + std::ofstream(dir / "bakedscale.json") + << R"({"tensors": [{"uid": 0, "is_runtime_pass_by_value": true, )" + R"("value_type": "Float32Value", "value": 2.0}]})"; + + EXPECT_THROW(loadIntegrationTestBundle(dir / "bakedscale.json"), + detail::RuntimePassByValueInvariantError); +} + TEST_F(TestBundleDiscoveryFixture, LoadBundleWrongSizeBinIsTensorLoadError) { auto dir = _tempDir / "op" / "badbin"; @@ -757,4 +808,137 @@ TEST_F(TestBundleDiscoveryFixture, UnusedSweepValueWarnsButLoadSucceeds) ASSERT_TRUE(std::holds_alternative(result)); } +// classifyBundle() is the testable decision step behind registerBundleTests(): +// it makes the same load-and-classify call that loop makes per discovered +// bundle, without touching ::testing::RegisterTest (which can only run before +// RUN_ALL_TESTS(), not from inside a running test body). These tests cover the +// routing itself — a good bundle becomes a LoadedBundle, a bad one becomes a +// FailedLoad — since nothing previously exercised that routing directly. +TEST_F(TestBundleDiscoveryFixture, ClassifyBundleReturnsLoadedBundleForGoodBundle) +{ + auto dir = _tempDir / "op" / "goodbundle"; + createLoadableBundle(dir, "goodbundle"); + + const auto discovered = discoverBundles(_tempDir); + ASSERT_EQ(discovered.size(), 1u); + + auto outcome = detail::classifyBundle(discovered.front()); + ASSERT_TRUE(std::holds_alternative(outcome)); + auto& loaded = std::get(outcome); + EXPECT_EQ(loaded.suiteName, discovered.front().suiteName); + EXPECT_EQ(loaded.testName, discovered.front().testName); + ASSERT_NE(loaded.bundle, nullptr); +} + +// Reuses the baked-value-plus-runtime-pass-by-value corruption from +// LoadTemplateSweepCaseWithBakedValueAndRuntimePassByValueIsError: that test +// confirms loadIntegrationTestBundle() throws RuntimePassByValueInvariantError +// for this case; this one confirms classifyBundle() catches that specific +// exception and turns it into a FailedLoad carrying the diagnostic path and +// reason, which is what lets registerBundleTests() surface it as a failing +// test instead of a log line. +TEST_F(TestBundleDiscoveryFixture, ClassifyBundleReturnsFailedLoadForRuntimePassByValueInvariant) +{ + const auto sweepDir = _tempDir / "quick" / "BatchnormFwdInference" / "Inference"; + createTemplateSweep(sweepDir, + {{"baked_runtime_scale_fp32_nchw", + "float", + {2, 3, 4, 5}, + {60, 20, 5, 1}, + {1, 3, 1, 1}, + {3, 1, 1, 1}}}); + + auto sweepJson = nlohmann::json::parse(std::ifstream(sweepDir / "sweep.json")); + sweepJson["cases"][0]["tensor_patches"] = nlohmann::json::array( + {{{"uid", 3}, + {"set", + {{"is_runtime_pass_by_value", true}, {"value_type", "Float32Value"}, {"value", 2.0}}}}}); + std::ofstream(sweepDir / "sweep.json") << sweepJson.dump(2); + + const auto discovered = discoverBundles(_tempDir); + ASSERT_EQ(discovered.size(), 1u); + + auto outcome = detail::classifyBundle(discovered.front()); + ASSERT_TRUE(std::holds_alternative(outcome)); + auto& failed = std::get(outcome); + EXPECT_EQ(failed.suiteName, discovered.front().suiteName); + EXPECT_EQ(failed.testName, discovered.front().testName); + EXPECT_NE(failed.message.find(discovered.front().diagnosticPath().string()), std::string::npos); + EXPECT_NE(failed.message.find("is_runtime_pass_by_value=true"), std::string::npos); +} + +// Only the RuntimePassByValueInvariantError contradiction gets a FailedLoad. +// An ordinary invalid-sweep-case failure (here: a case referencing a golden +// path that was never created) must keep the original behavior — logged and +// classified as SkippedLoad, no failing test registered — so this fix doesn't +// widen every pre-existing load failure into a hard suite failure. +TEST_F(TestBundleDiscoveryFixture, ClassifyBundleReturnsSkippedLoadForOrdinaryInvalidSweepCase) +{ + createTemplateSweep(_tempDir / "quick" / "BatchnormFwdInference" / "Inference", + {{"missing_path_fp32_nchw", + "float", + {2, 3, 4, 5}, + {60, 20, 5, 1}, + {1, 3, 1, 1}, + {3, 1, 1, 1}, + true, + false}}); + + const auto discovered = discoverBundles(_tempDir); + ASSERT_EQ(discovered.size(), 1u); + + auto outcome = detail::classifyBundle(discovered.front()); + ASSERT_TRUE(std::holds_alternative(outcome)); + auto& skipped = std::get(outcome); + EXPECT_NE(skipped.message.find(discovered.front().diagnosticPath().string()), + std::string::npos); + EXPECT_NE(skipped.message.find(toString(LoadError::INVALID_SWEEP_CASE)), std::string::npos); +} + +// Direct regression test for the original review repro: corrupting one sweep +// case must not affect classification of an unrelated, valid bundle +// discovered alongside it. +TEST_F(TestBundleDiscoveryFixture, ClassifyBundleIsolatesFailureAmongMultipleDiscoveredBundles) +{ + auto goodDir = _tempDir / "op" / "goodbundle"; + createLoadableBundle(goodDir, "goodbundle"); + + const auto sweepDir = _tempDir / "quick" / "BatchnormFwdInference" / "Inference"; + createTemplateSweep(sweepDir, + {{"baked_runtime_scale_fp32_nchw", + "float", + {2, 3, 4, 5}, + {60, 20, 5, 1}, + {1, 3, 1, 1}, + {3, 1, 1, 1}}}); + auto sweepJson = nlohmann::json::parse(std::ifstream(sweepDir / "sweep.json")); + sweepJson["cases"][0]["tensor_patches"] = nlohmann::json::array( + {{{"uid", 3}, + {"set", + {{"is_runtime_pass_by_value", true}, {"value_type", "Float32Value"}, {"value", 2.0}}}}}); + std::ofstream(sweepDir / "sweep.json") << sweepJson.dump(2); + + const auto discovered = discoverBundles(_tempDir); + ASSERT_EQ(discovered.size(), 2u); + + const auto* goodBundle = findByTest(discovered, "goodbundle"); + const auto* badBundle = findByTest(discovered, "baked_runtime_scale_fp32_nchw"); + ASSERT_NE(goodBundle, nullptr); + ASSERT_NE(badBundle, nullptr); + + EXPECT_TRUE(std::holds_alternative(detail::classifyBundle(*goodBundle))); + EXPECT_TRUE(std::holds_alternative(detail::classifyBundle(*badBundle))); +} + +// Closes the loop between "classifyBundle() decided this bundle failed" and +// "the failing test GTest actually runs really fails": constructs the +// synthetic test body directly and confirms it records exactly the stored +// message as a non-fatal failure, the same way GTest would run it once +// registerFailedBundleLoad() has registered it. +TEST_F(TestBundleDiscoveryFixture, FailedBundleLoadTestRecordsFailureWithMessage) +{ + detail::FailedBundleLoadTest test("boom"); + EXPECT_NONFATAL_FAILURE(test.TestBody(), "boom"); +} + // NOLINTEND(readability-identifier-naming) From 11e2fe6bf752fae251caaeccdf7a832f0f193081 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Tue, 4 Aug 2026 10:26:43 -0600 Subject: [PATCH 8/9] test(hipdnn): cover attn_scale as a runtime pass-by-value scalar in SDPA tests The compatible-optional-attributes tests for SDPA forward and backward descriptor lifting/lowering already verified that dropout_probability and the diagonal band bounds are captured correctly as runtime scalars, but did not exercise attn_scale through the same path even though it takes the same tensor-or-scalar dual representation. Setting attn_scale via set_attn_scale() and asserting attn_scale_value on the lowered/lifted attributes closes that gap, alongside the existing assertion that the tensor form of attn_scale remains unset in these tests. ALMIOPEN-2267 --- .../tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp | 4 ++++ projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp | 3 +++ .../tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp index 665e2071f5fb..67b9d861e3cd 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdDescriptorLowering.cpp @@ -398,6 +398,7 @@ TEST_F(IntegrationSdpaBwdDescriptorLowering, SdpaBwdWithAllOptionalTensorsAndSca sdpaAttrs.set_padding_mask(true); sdpaAttrs.set_causal_mask(true); sdpaAttrs.set_causal_mask_bottom_right(true); + sdpaAttrs.set_attn_scale(0.125f); sdpaAttrs.set_diagonal_band_left_bound(0); sdpaAttrs.set_diagonal_band_right_bound(128); sdpaAttrs.set_diagonal_alignment(DiagonalAlignment::BOTTOM_RIGHT); @@ -581,6 +582,9 @@ TEST_F(IntegrationSdpaBwdDescriptorLowering, SdpaBwdWithAllOptionalTensorsAndSca ASSERT_TRUE(sdpa->dropout_probability.has_value()); EXPECT_FLOAT_EQ(sdpa->dropout_probability.value(), 0.1f); + ASSERT_TRUE(sdpa->attn_scale_value.has_value()); + EXPECT_FLOAT_EQ(sdpa->attn_scale_value.value(), 0.125f); + // Integer scalars ASSERT_TRUE(sdpa->left_bound.has_value()); EXPECT_EQ(sdpa->left_bound.value(), 0); diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp index 91601b0a807d..60eef6658782 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaBwdLifting.cpp @@ -338,6 +338,7 @@ TEST_F(IntegrationSdpaBwdLifting, SdpaBwdWithCompatibleOptionalAttributesViaCApi .set_padding_mask(true) .set_causal_mask(true) .set_causal_mask_bottom_right(true) + .set_attn_scale(0.125f) .set_diagonal_band_left_bound(-1) .set_diagonal_band_right_bound(1) .set_diagonal_alignment(DiagonalAlignment::BOTTOM_RIGHT); @@ -459,6 +460,8 @@ TEST_F(IntegrationSdpaBwdLifting, SdpaBwdWithCompatibleOptionalAttributesViaCApi // Scalar values ASSERT_TRUE(attrs.dropout_probability.has_value()); EXPECT_FLOAT_EQ(attrs.dropout_probability.value(), 0.1f); + ASSERT_TRUE(attrs.attn_scale_value.has_value()); + EXPECT_FLOAT_EQ(attrs.attn_scale_value.value(), 0.125f); ASSERT_TRUE(attrs.left_bound.has_value()); EXPECT_EQ(attrs.left_bound.value(), -1); ASSERT_TRUE(attrs.right_bound.has_value()); diff --git a/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp b/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp index 71dbbde8c90c..d0286bd3cc69 100644 --- a/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp +++ b/projects/hipdnn/tests/frontend/IntegrationSdpaFwdDescriptorLifting.cpp @@ -352,6 +352,7 @@ TEST_F(IntegrationSdpaFwdDescriptorLifting, SdpaFwdWithCompatibleOptionalAttribu .set_causal_mask(true) .set_causal_mask_bottom_right(true) .set_generate_stats(true) + .set_attn_scale(0.125f) .set_diagonal_band_left_bound(-1) .set_diagonal_band_right_bound(1) .set_paged_attention_max_seq_len_kv(256) @@ -445,6 +446,8 @@ TEST_F(IntegrationSdpaFwdDescriptorLifting, SdpaFwdWithCompatibleOptionalAttribu // Scalar values (direct member access) ASSERT_TRUE(attrs.dropout_probability.has_value()); EXPECT_FLOAT_EQ(attrs.dropout_probability.value(), 0.1f); + ASSERT_TRUE(attrs.attn_scale_value.has_value()); + EXPECT_FLOAT_EQ(attrs.attn_scale_value.value(), 0.125f); ASSERT_TRUE(attrs.left_bound.has_value()); EXPECT_EQ(attrs.left_bound.value(), -1); ASSERT_TRUE(attrs.right_bound.has_value()); From bb46b553f3bce1ddeb2dd9fdfb3027121e598b77 Mon Sep 17 00:00:00 2001 From: Garby Gilbert Date: Tue, 4 Aug 2026 10:27:03 -0600 Subject: [PATCH 9/9] refactor(integration-tests): rename FailedBundleLoadTestRecordsFailureWithMessage The test name validator rejects GTest case names containing keywords such as "Test", since they belong in the suite name rather than the case name. Renaming the case to FailedBundleLoadRecordsFailureWithMessage satisfies that rule without changing what the test covers. ALMIOPEN-2267 --- dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp b/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp index a1a2487fd91f..9241f386fe52 100644 --- a/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp +++ b/dnn-providers/integration-tests/tests/TestBundleDiscovery.cpp @@ -935,7 +935,7 @@ TEST_F(TestBundleDiscoveryFixture, ClassifyBundleIsolatesFailureAmongMultipleDis // synthetic test body directly and confirms it records exactly the stored // message as a non-fatal failure, the same way GTest would run it once // registerFailedBundleLoad() has registered it. -TEST_F(TestBundleDiscoveryFixture, FailedBundleLoadTestRecordsFailureWithMessage) +TEST_F(TestBundleDiscoveryFixture, FailedBundleLoadRecordsFailureWithMessage) { detail::FailedBundleLoadTest test("boom"); EXPECT_NONFATAL_FAILURE(test.TestBody(), "boom");