Skip to content

Conversation

rdspring1
Copy link
Collaborator

Returning std::unique_ptr explicitly signals exclusive ownership transfer to Python.
Returning new use the default policy for pointer, which is return_value_policy::take_ownership.

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

!test

Copy link

github-actions bot commented Oct 2, 2025

Description

  • Use std::make_unique for safe ownership transfer

  • Replace raw new with smart pointers in bindings

  • Update version to reflect changes


Changes walkthrough 📝

Relevant files
Enhancement
multidevice.cpp
Use unique_ptr for DeviceMesh in bindings                               

python/python_direct/multidevice.cpp

  • Replace new DeviceMesh with std::make_unique
  • Maintain backward compatibility for integer list input
  • +2/-2     
    runtime.cpp
    Use unique_ptr for FusionExecutorCache                                     

    python/python_direct/runtime.cpp

  • Replace new FusionExecutorCache with std::make_unique
  • Ensure exclusive ownership transfer to Python
  • +1/-1     
    Configuration changes
    version.txt
    Update version number                                                                       

    python/version.txt

    • Bump version from 0.2.34 to 0.2.35
    +1/-1     

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    ⚡ Recommended focus areas for review

    Ownership Clarity

    The use of std::make_unique correctly transfers exclusive ownership to Python, but it should be confirmed that the pybind11 bindings properly handle std::unique_ptr return types to avoid memory leaks or undefined behavior.

    return std::make_unique<DeviceMesh>(std::move(devices));
    Unique Pointer Initialization

    The nested use of std::make_unique for both FusionExecutorCache and Fusion should be validated to ensure correct object construction and ownership transfer, particularly under error or exception conditions.

    return std::make_unique<FusionExecutorCache>(
        std::make_unique<Fusion>(*fusion), fusion_id, auto_schedule);

    @rdspring1 rdspring1 requested a review from jjsjann123 October 3, 2025 16:45
    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.

    1 participant