- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Fix JAX Layout tiling argument for JAX 0.7.1 #133
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @hertschuh, 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 addresses a breaking change in JAX 0.7.1 by updating how the jax.experimental.layout.Layout class is instantiated. The core change involves adapting to a renamed argument, ensuring that the codebase remains functional and compatible with both newer and older versions of the JAX library.
Highlights
- JAX API Compatibility: Updated the usage of jax.experimental.layout.Layoutto account for the_tilingargument being renamed totilingin JAX version 0.7.1.
- Backward Compatibility: Implemented version-aware logic using jax.__version_info__to dynamically select between thetiling(for JAX 0.7.1+) and_tiling(for older JAX versions) arguments, ensuring the code remains compatible across different JAX environments.
- Code Refinement: Introduced a local layoutvariable to encapsulate the version-dependentLayoutClassinstantiation, improving readability and maintainability in both the main implementation and its test utility.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 or fill out our survey to provide feedback.
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
- 
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. ↩ 
There was a problem hiding this 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 addresses a breaking change in JAX version 0.7.1 by renaming the _tiling argument to tiling for jax.experimental.layout.Layout. The changes are applied to both the main implementation and the corresponding test file. My feedback focuses on improving code maintainability by reducing duplication in the newly added conditional logic. I've suggested refactoring the LayoutClass instantiation to avoid repeating common arguments, which should make the code cleaner and easier to maintain.
| layout = ( | ||
| LayoutClass(major_to_minor=(0, 1), tiling=((8,),)) | ||
| if jax.__version_info__ >= (0, 7, 1) | ||
| else LayoutClass(major_to_minor=(0, 1), _tiling=((8,),)) # type: ignore | ||
| ) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and reduce code duplication, you can factor out the common arguments for LayoutClass into a dictionary. This makes the conditional logic cleaner and avoids repeating arguments.
common_kwargs = {"major_to_minor": (0, 1)}
layout = (
    LayoutClass(**common_kwargs, tiling=((8,),))
    if jax.__version_info__ >= (0, 7, 1)
    else LayoutClass(**common_kwargs, _tiling=((8,),))  # type: ignore| layout = ( | ||
| LayoutClass(major_to_minor=(0, 1), tiling=((8,),)) | ||
| if jax.__version_info__ >= (0, 7, 1) | ||
| else LayoutClass(major_to_minor=(0, 1), _tiling=((8,),)) # type: ignore | ||
| ) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and reduce code duplication, you can factor out the common arguments for LayoutClass into a dictionary. This makes the conditional logic cleaner and avoids repeating arguments.
common_kwargs = {"major_to_minor": (0, 1)}
layout = (
    LayoutClass(**common_kwargs, tiling=((8,),))
    if jax.__version_info__ >= (0, 7, 1)
    else LayoutClass(**common_kwargs, _tiling=((8,),))  # type: ignoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The `jax.experimental.layout.Layout` argument is renamed from `_tiling` to `tiling`.
The
jax.experimental.layout.Layoutargument is renamed from_tilingtotiling.