Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ggml/src/ggml-hrx/dispatch/command-plan.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ inline const CommandPlanAlternateValue * find_alternate_value(const Graph &
}

for (const CommandPlanAlternateValue & alternate : plan.metadata.alternate_values()) {
if (alternate.type != type || alternate.byte_count != byte_count) {
// the scale is part of what a reader asks for: a copy stored at another scale is a different value (engine #2159)
if (alternate.type != type || alternate.byte_count != byte_count || alternate.scale_log2 != scale_log2) {
continue;
}
const Value * alternate_value = graph.values().find(alternate.graph_value);
Expand Down
19 changes: 19 additions & 0 deletions tests/hrx-backend-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8469,6 +8469,25 @@ static void run_alias_value_import_checks() {
REQUIRE(aliased_binding->offset == 64);
REQUIRE(aliased_binding->length == 8 * sizeof(float));

// engine #2159: an alternate stored at a scale is found only by a reader that asks for that scale, also through an
// alias. Value 1 aliases value 0; value 0 has an f16 copy stored at 2^-6.
{
ggml::hrx::Graph alias_graph;
alias_graph.values() = value_map;
ggml::hrx::CommandPlan alias_plan;
ggml::hrx::Status alias_status;
REQUIRE(alias_plan.metadata.append_alternate_value(
{ ggml::hrx::ValueId(0), ggml::hrx::ValueId(7), GGML_TYPE_F16, 16, "test.scaled_f16", 6 }, alias_status));
const auto * scaled =
ggml::hrx::find_alternate_value(alias_graph, alias_plan, ggml::hrx::ValueId(1), GGML_TYPE_F16, 16, 6);
REQUIRE(scaled != nullptr);
REQUIRE(scaled->scale_log2 == 6);
REQUIRE(ggml::hrx::find_alternate_value(alias_graph, alias_plan, ggml::hrx::ValueId(1), GGML_TYPE_F16, 16) ==
nullptr);
REQUIRE(ggml::hrx::find_alternate_value(alias_graph, alias_plan, ggml::hrx::ValueId(0), GGML_TYPE_F16, 16) ==
nullptr);
}

ggml_free(ctx);
}

Expand Down