Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rdspring1
Copy link
Collaborator

No description provided.

@rdspring1 rdspring1 added the Direct Bindings Python extension with direct mapping to NvFuser CPP objects. label Sep 23, 2025
@rdspring1
Copy link
Collaborator Author

!build

Copy link

github-actions bot commented Sep 23, 2025

Review updated until commit 116baac

Description

  • Add README for Direct Bindings API

  • Document differences from legacy Python API

  • Guide on adding IR nodes and operations

  • Include debugging steps for PythonTranslator


Changes walkthrough 📝

Relevant files
Documentation
README.md
Add comprehensive README for Direct Bindings                         

python/python_direct/README.md

  • Introduce Direct Bindings API for CPP-to-Python mapping
  • Explain differences from legacy API, including lack of caching and
    RecordFunctor
  • Provide instructions for adding IR nodes and operations
  • Include debugging workflow using gdb and exception catching
  • +44/-0   

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    ⚡ No major issues detected

    Copy link
    Collaborator

    @jjsjann123 jjsjann123 left a comment

    Choose a reason for hiding this comment

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

    Thanks a ton for updating this.


    ## How to add new Operation?
    * Add operation to `python_direct/ops.cpp` with docstring.
    * If operations corresponds with a new Expr node, add `void handle(const SomeOp*) final` to `python_direct/python_translate.cpp`.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    naive question: is an Operation not necessarily an Expr?

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    broadcast_in_dim is a composite operation of BroadcastOp and ExpandOp. You may not need to add a handle function for composite operations.

    3. Add output values for Expr node to `visited_vals_`.
    4. Create dynamic scalar input arguments. This step is for view and expand operations. TensorView input arguments are handled via DAG traversal. Constant scalars are added directly to python defintion.
    5. Use `PythonPrinter::generateOperation` if the operation only uses positional arguments. This is mainly used for unary and binary operations.
    6. Use `PythonPrinter::generateKwargsOperation` if the operation uses keyword arguments. If none of the keyword arguments have default arguments, create a static vector of strings. If some of the keyword arguments have default arguments, create a vector of KeywordArgument. The KeywordArgument struct hold default values for keyword arguments. Use `std::nullopt` for keyword arguments without default values.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    👏 nice to have.

    though I felt the examples in python_translate.cpp was already pretty decent. 😜

    @rdspring1
    Copy link
    Collaborator Author

    !build

    @rdspring1 rdspring1 merged commit 884eba5 into main Sep 26, 2025
    17 checks passed
    @rdspring1 rdspring1 deleted the direct_readme branch September 26, 2025 16:27
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Direct Bindings Python extension with direct mapping to NvFuser CPP objects.
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants