Skip to content

Hugr::canonicalize_nodes() doesn't always canonicalize node indices #2789

@cqc-alec

Description

@cqc-alec

The function check_hugr_equality() (which is used as part of hugr validation to compare a hugr with the result of a serialization/deserialization round-trip) first calls canonicalize_nodes() on each hugr, and then compares them node by node. However, canonicalize_nodes() does not correct all irrelevant differences in node numbering.

Currently the validate() method works around this by using the json serialization instead of the model serialization. But when the model serialization is used instead, many of the tests fail because we end up comparing two hugrs containing Const and LoadConstant nodes that are numbered in a different order, and canonicalize_nodes() does not correct this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions