Skip to content

Comments

Compression: automatically propagate constants and remove unused nodes#8

Merged
jjcmoon merged 6 commits intomainfrom
propagate-bool-constants
Feb 6, 2025
Merged

Compression: automatically propagate constants and remove unused nodes#8
jjcmoon merged 6 commits intomainfrom
propagate-bool-constants

Conversation

@VincentDerk
Copy link
Collaborator

@VincentDerk VincentDerk commented Jan 29, 2025

Re-enables the propagation of constants (true or false), and the removal of unused nodes (those not connected to a root node).

  • The propagation of constants happens automatically while adding nodes to the circuit.
  • The removal happens when calling circuit.tensorize(), or when manually calling circuit.remove_unused_nodes().
    Users should be aware that Python references to unused nodes become invalid after calling .tensorize().

This PR adds additional tests for the propagation and elimination. I confirm all tests pass, also those in DeepLog.

This PR additionally exposes through the Python interface: .nb_root_nodes(), .remove_unused_nodes(), and klay.utils.circuit_to_dot(circuit, dot_filepath). The latter is more for debugging purposes.

Worst case in the future, we can again quickly disable this like before

Node* Circuit::add_node_level_compressed(Node* node) {
    // return add_node_level(node); // <--- uncomment to disable
    ...
std::pair<Arrays, Arrays> Circuit::tensorize() {
    remove_unused_nodes();  // <--- comment to disable
    add_root_layer();
    ....

@jjcmoon
Copy link
Member

jjcmoon commented Feb 6, 2025

lgtm!

@jjcmoon jjcmoon merged commit 6cc9e99 into main Feb 6, 2025
10 of 12 checks passed
@jjcmoon jjcmoon deleted the propagate-bool-constants branch February 6, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants