Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic routine visualization and update README #4

Merged
merged 17 commits into from
Mar 25, 2024

Conversation

dexter2206
Copy link
Contributor

This adds very basic routine visualization in a form of Graphviz digraphs. Visualizations can be obtained by:

  • Calling to_graphviz(routine) function.
  • Running hqar-render <input-path> <output-path> CLI tool.

The visualization capabilities are placed in hqar.experimental.rendering submodule. I decided to use intermediate experimental namespace to make the instability of this feature painfully obvious.

In addition this PR contains several boy-scout improvements:

  • Corrects handling of copyright notice by flake8
  • Moves loading of valid program examples into fixture. This was needed so that we can reuse the data-loading function without doing some convoluted import logic.
    • This forced another change, namely splitting the large example file into smaller example files (one file per example). I actually think that current organization is better, it wasn't the intended effect though.

@dexter2206 dexter2206 requested a review from mstechly March 21, 2024 23:29
@dexter2206 dexter2206 changed the title Add basic routine visualization Add basic routine visualization and update README Mar 22, 2024
Copy link
Contributor

@mstechly mstechly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, merge when ready!

README.md Show resolved Hide resolved
README.md Outdated

## HQAR format

Consider the following hierarchical dag a hypothetical quantum program:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it would be good to explain what we mean by "hierarchical" and what "dag" is.

Perhaps we could start this section with sth like:

Important terms we use when talking about HQAR objects are:

  • hierarchical graphs – this means that each node of the graph can contain a graph inside it
  • DAG – directed acyclic graphs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to explain those concepts in d16ffba, WDYT?

Experimental visualization capabilities for HQAR.

Currently, the visualizations are done with graphviz, which does not suport
hierarchical structures. Therefore, we have to use a somewhat tricky representation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess "hacky" might be a better word here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1a27cb9 reworded.

# Dictionary of default graph attributes, used for non-leaf nodes
GRAPH_ATTRS = {
"rankdir": "LR", # Draw left to right (default is top to bottom)
"fontname": "Helvetica", # Some font properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this comment is not necessary ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but to explain myself I had more font properties initially and it served as a header 😂 Fixed in 304db14

@dexter2206 dexter2206 merged commit 057e39b into main Mar 25, 2024
5 checks passed
@dexter2206 dexter2206 deleted the kj/add-rudimentary-program-visualization branch March 25, 2024 15:02
mstechly pushed a commit that referenced this pull request Apr 24, 2024
* Implement rendering to graphviz DAG

* Minor style fixes

* Add script for rendering serialized diagram

* Rename: hqar.experimental.visualization -> hqar.experimental.rendering

* Add flake8-copyright to pre-commit hooks

* Move loading of valid test programs to fixture

* Fix typo

* Add tests for rendering

* Add graphviz to dependencies

* Add GH action step with graphviz setup

* Make mypy ignore graphviz errors

* Add good-enough initial README

* Expand README

* Explain hierarchy and DAG in README

* Remove unnecessary comment

* List visualization tool as one of features

* Reword tricky -> hacky

---------

Co-authored-by: Konrad Jałowiecki <kjalowiecki@psiquantum.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants