Skip to content

Feat: Finalize Polyhedral Compiler Stuff#17

Merged
hikettei merged 73 commits intomainfrom
hikettei/polyhedral
Dec 24, 2025
Merged

Feat: Finalize Polyhedral Compiler Stuff#17
hikettei merged 73 commits intomainfrom
hikettei/polyhedral

Conversation

@hikettei
Copy link
Owner

@hikettei hikettei commented Dec 18, 2025

  • Conv2D+Pool2D Fusion
  • Complete a set of loop transformations
  • Renderer

@github-actions
Copy link

🤖 Hi @hikettei, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@gemini-code-assist
Copy link

Summary of Changes

Hello @hikettei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on finalizing the polyhedral compiler examples by updating and refactoring the associated Jupyter notebooks. The changes ensure that the examples are executable, their outputs are captured for immediate viewing, and the polyhedral_compiler.ipynb is streamlined with modular functions for defining schedules for common operations, enhancing the overall quality and maintainability of the examples.

Highlights

  • Notebook Execution and Output Capture: The isl_tutorial.ipynb and polyhedral_compiler.ipynb notebooks have been updated to include their execution outputs, ensuring that the examples are readily viewable and verifiable without needing to run them manually. This also includes adding necessary sys.path modifications for correct module imports.
  • Polyhedral Compiler Example Refactoring: The polyhedral_compiler.ipynb notebook has been significantly refactored. Previous detailed examples for matrix multiplication and convolution/pooling fusion have been replaced with more modular helper functions (create_conv_schedule, create_pool_schedule) that define polyhedral schedules for Conv2D and Pool2D operations, improving clarity and reusability.
  • Python Kernel Version Update: The isl_tutorial.ipynb notebook's metadata was updated to reflect a change in the Python kernel version from 3.12.5 to 3.11.10.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🤖 I'm sorry @hikettei, but I was unable to process your request. Please see the logs for more details.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates two example notebooks by executing the code cells and committing the outputs. While this is helpful for isl_tutorial.ipynb, the polyhedral_compiler.ipynb has been significantly refactored, removing the complete examples for matrix multiplication and convolution fusion. It now only contains helper function definitions without any usage, making the example incomplete. It's unclear if this is intentional, but it reduces the value of the notebook as a demonstration. Additionally, both notebooks now modify sys.path to resolve imports, which is not ideal. I've added specific comments with suggestions for improvement.

Comment on lines 50 to 51
"import sys\n",
"sys.path.append(\"../\")\n",

Choose a reason for hiding this comment

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

medium

Modifying sys.path at runtime is generally discouraged as it can lead to unexpected behavior and makes the code less portable. A better approach for running example notebooks is to either:

  1. Run the Jupyter server from the root of the repository. This way, the caten package will be in the Python path.
  2. Install the package in editable mode using pip install -e . from the repository root.

This avoids runtime modifications to the path.

Comment on lines +42 to +43
"import sys\n",
"sys.path.append(\"../\")\n",

Choose a reason for hiding this comment

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

medium

Modifying sys.path at runtime is generally discouraged as it can lead to unexpected behavior and makes the code less portable. A better approach for running example notebooks is to either:

  1. Run the Jupyter server from the root of the repository. This way, the caten package will be in the Python path.
  2. Install the package in editable mode using pip install -e . from the repository root.

This avoids runtime modifications to the path.

"# Pool Domain: Output of Pool is H/2 x W/2\n",
"H_out, W_out = H // Pool_S, W // Pool_S\n",
"pool_dom = f\"{{ Pool[n, c, h, w] : 0 <= n < {N} and 0 <= c < {C} and 0 <= h < {H_out} and 0 <= w < {W_out} }}\" # noqa\n",
"def create_conv_schedule(N, K_out, H_out, W_out, Cin, KH, KW):\n",

Choose a reason for hiding this comment

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

medium

The parameter name Cin is inconsistent with other parameters like K_out, H_out, etc. To improve consistency and readability, consider renaming it to C_in. This would align with the naming convention used for other dimensions in this context.

def create_conv_schedule(N, K_out, H_out, W_out, C_in, KH, KW):

"H_out, W_out = H // Pool_S, W // Pool_S\n",
"pool_dom = f\"{{ Pool[n, c, h, w] : 0 <= n < {N} and 0 <= c < {C} and 0 <= h < {H_out} and 0 <= w < {W_out} }}\" # noqa\n",
"def create_conv_schedule(N, K_out, H_out, W_out, Cin, KH, KW):\n",
" dom_str = f\"{{ S_conv[n, k, h, w, c, kh, kw] : 0<=n<{N} and 0<=k<{K_out} and 0<=h<{H_out} and 0<=w<{W_out} and 0<=c<{Cin} and 0<=kh<{KH} and 0<=kw<{KW} }}\"\n",

Choose a reason for hiding this comment

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

medium

This line is very long and hard to read. For better readability, consider breaking it into multiple lines using parentheses.

    dom_str = (
        f"{{ S_conv[n, k, h, w, c, kh, kw] : "
        f"0<=n<{N} and 0<=k<{K_out} and 0<=h<{H_out} and 0<=w<{W_out} and "
        f"0<=c<{Cin} and 0<=kh<{KH} and 0<=kw<{KW} }}"
    )

"We can use the `compute_at` method to automatically embed the Producer (Conv) schedule into the Consumer (Pool) schedule, based on dependency analysis.\n"
"def create_pool_schedule(N, K_out, H_pool, W_pool, S_pool, KH_pool, KW_pool):\n",
" # Pool Domain\n",
" dom_str = f\"{{ S_pool[n, k, h, w, rh, rw] : 0<=n<{N} and 0<=k<{K_out} and 0<=h<{H_pool} and 0<=w<{W_pool} and 0<=rh<{KH_pool} and 0<=rw<{KW_pool} }}\"\n",

Choose a reason for hiding this comment

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

medium

Similar to the create_conv_schedule function, this line is quite long. Breaking it into multiple lines would improve readability.

    dom_str = (
        f"{{ S_pool[n, k, h, w, rh, rw] : "
        f"0<=n<{N} and 0<=k<{K_out} and 0<=h<{H_pool} and 0<=w<{W_pool} and "
        f"0<=rh<{KH_pool} and 0<=rw<{KW_pool} }}"
    )

@hikettei hikettei marked this pull request as ready for review December 24, 2025 15:44
@hikettei hikettei merged commit ab5e6f1 into main Dec 24, 2025
4 checks passed
@hikettei hikettei deleted the hikettei/polyhedral branch December 24, 2025 15:44
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.

1 participant