Skip to content

Remove legacy bindings#5917

Open
rdspring1 wants to merge 4 commits intomainfrom
remove_legacy_bindings
Open

Remove legacy bindings#5917
rdspring1 wants to merge 4 commits intomainfrom
remove_legacy_bindings

Conversation

@rdspring1
Copy link
Collaborator

This PR removes the nvfuser python module, corresponding pybind11 CPP bindings, and any references from csrc. Version is bumped to 0.2.36.

@rdspring1 rdspring1 added the Direct Bindings Python extension with direct mapping to NvFuser CPP objects. label Feb 3, 2026
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Review updated until commit d21881d

Description

  • Remove legacy nvfuser python module and bindings completely

  • Keep only nvfuser_direct module as the supported Python interface

  • Update build system to only compile nvfuser_direct extension

  • Fix LaunchParams initialization to avoid CUDA context creation on import

  • Update documentation and test references to use nvfuser_direct

  • Add NVF_API visibility annotations for proper symbol export

Changes walkthrough

Relevant files
Enhancement
7 files
version.txt
Bump version from 0.2.35 to 0.2.36                                             
+1/-1     
CMakeLists.txt
Remove nvfuser python library build, keep only nvfuser_direct
+3/-141 
utils.py
Remove nvfuser._C extension handling, keep only nvfuser_direct
+2/-7     
check_symbol_visibility.sh
Remove nvfuser extension checks, keep only nvfuser_direct
+1/-17   
runtime.cpp
Use std::optional for LaunchParams to avoid CUDA context on import
+13/-6   
type.h
Add NVF_API visibility annotations for operator<< functions
+2/-2     
utils.h
Add NVF_API visibility annotation for getShardedLogicalAxis
+2/-1     
Documentation
5 files
autotune_inner_reduction.py
Add TODO comment to update script to use nvfuser_direct   
+2/-0     
autotune_pointwise.py
Add TODO comment to update script to use nvfuser_direct   
+2/-0     
autotune_matmul.py
Add TODO comment to update script to use nvfuser_direct   
+2/-0     
profile_matmul.py
Add TODO comment to update script to use nvfuser_direct   
+1/-0     
Serde.md
Update documentation about serialization being disabled   
+3/-1     
Miscellaneous
1 files
fusion_segmenter.cpp
Update test reference URL in comment                                         
+1/-1     
Additional files
36 files
options.cpp +0/-2     
options.h +0/-2     
fusion_kernel_runtime.cpp +0/-12   
fusion_record.cpp +0/-952 
fusion_record.h +0/-124 
README.md +0/-210 
__init__.py +0/-649 
__init__.pyi +0/-4     
benchmark_utils.py +0/-160 
__init__.py +0/-9     
__init__.py +0/-13   
normalization.py +0/-725 
nvfuser_version.py +0/-69   
pytorch_utils.py +0/-190 
fusion_cache.cpp +0/-953 
fusion_cache.h +0/-320 
fusion_definition.cpp +0/-769 
fusion_definition.h +0/-389 
fusion_record.h +0/-3675
fusion_state.cpp +0/-297 
fusion_state.h +0/-143 
multidevice_bindings.cpp +0/-103 
python_bindings.cpp +0/-4196
python_bindings.h +0/-27   
python_bindings_extension.cpp +0/-18   
schedule_bindings.cpp +0/-517 
segmentation.cpp +0/-369 
segmentation.h +0/-246 
translation.cpp +0/-1484
translation.h +0/-20   
translation_utils.cpp +0/-80   
translation_utils.h +0/-300 
test_import.py +0/-17   
__init__.py +0/-6     
utils.py +0/-358 
env_options.yaml +0/-12   

PR Reviewer Guide

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review
API Signature Changes

The KernelExecutor compile() and run() methods have been modified to make launch_constraints optional with default values. This is a breaking API change that could affect existing code using these methods. Ensure that all calling code has been updated accordingly and that this change is properly documented.

    py::arg("group_id") = 0)
.def(
    "compile",
    [](KernelExecutor& self,
       Fusion* fusion,
       const py::iterable& args,
       std::optional<LaunchParams> launch_constraints,
       const CompileParams& compile_params,
       SchedulerType scheduler_type) {
      // launch_constraints is optional to avoid creating default
      // LaunchParams when importing shared library.
      self.compile(
          fusion,
          from_pyiterable(args),
          launch_constraints.value_or(LaunchParams()),
          compile_params,
          scheduler_type);
    },
Build Configuration Logic

The build_extension method now only handles nvfuser_direct._C_DIRECT extension, removing the conditional logic for the legacy nvfuser._C extension. This appears correct given the PR goal, but verify that no other build configurations depend on the removed logic.

def build_extension(self, ext):
    if ext.name == "nvfuser_direct._C_DIRECT":
        self.copy_library(ext, "libnvfuser_direct")
        self.copy_shared_library("libnvfuser_codegen.so")
    else:
        super().build_extension(ext)
Symbol Visibility

The getShardedLogicalAxis function declaration was moved and now has NVF_API visibility annotation. This change in symbol visibility could affect linking and should be verified to ensure proper symbol export.

NVF_API int64_t
getShardedLogicalAxis(const TensorView* tv, ParallelType parallel_type);

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 3, 2026

Greptile Summary

This PR removes the legacy nvfuser Python module, its entire python_frontend C++ binding layer (~17,500 lines deleted), and related references from csrc. It retains the newer nvfuser_direct module as the sole Python API. Version is bumped to 0.2.36.

Key changes:

  • Deletes the entire python/nvfuser/ package and python/python_frontend/ directory
  • Removes the nvfuser CMake build target and associated build configuration
  • Removes csrc/serde/fusion_record.{cpp,h} which supported legacy serialization
  • Removes PythonDefinitionSegments and PythonFrontendDebug debug dump options from csrc/options.{h,cpp} and fusion_kernel_runtime.cpp
  • Removes legacy test utilities (tests/python/utils/) and import-conflict tests
  • Moves python_common sources (distributed_tensor, python_utils, translation_names) into the nvfuser_direct build target
  • Adds NVF_API visibility annotations to UnaryOpType, TernaryOpType operators and getShardedLogicalAxis needed by nvfuser_direct
  • Changes LaunchParams default argument in runtime.cpp to std::optional to avoid construction at import time
  • Cleans up tools/check_symbol_visibility.sh and tools/env-config/env_options.yaml

Remaining items to address:

  • doc/dev/python_scheduling/ scripts (autotune_utils.py, autotune_persistent.py, autotune_inner_reduction.py, autotune_matmul.py, autotune_pointwise.py, profile_matmul.py) still have unconditional from nvfuser import ... statements and will fail at runtime. TODOs were added to four of them but the imports were not updated.
  • python/utils.py still includes include/nvfuser/python_frontend/*.h in nvfuser_common_package_data, but those headers no longer exist.

Confidence Score: 4/5

  • This PR is a large but straightforward deletion with minor leftover references that need cleanup.
  • The core removal is clean and thorough — all legacy C++ bindings, Python modules, CMake targets, and debug options are consistently removed. The nvfuser_direct build correctly picks up the formerly shared python_common sources. The LaunchParams optional change is a sound approach. Score is 4 instead of 5 because several doc/dev scripts remain broken with stale nvfuser imports, and there's a stale package_data glob.
  • doc/dev/python_scheduling/ scripts (autotune_utils.py, autotune_persistent.py not in changeset) and python/utils.py (stale python_frontend package data glob)

Important Files Changed

Filename Overview
CMakeLists.txt Removes nvfuser legacy Python library build target and related cmake config; moves python_common sources into nvfuser_direct build. Clean removal.
csrc/multidevice/utils.h Adds NVF_API visibility annotation to getShardedLogicalAxis, needed now that nvfuser_direct links against codegen directly.
csrc/options.h Removes PythonDefinitionSegments and PythonFrontendDebug enum values from DebugDumpOption.
csrc/runtime/fusion_kernel_runtime.cpp Removes includes and debug-dump code for PythonDefinitionSegments that used the now-removed python_frontend translation. Clean removal.
csrc/serde/Serde.md Adds a note that serialization is disabled but the rest of the document still describes removed python_frontend code (FusionCache, RecordFunctor, Trie, etc.).
csrc/type.h Adds NVF_API to UnaryOpType and TernaryOpType operator<< for symbol visibility in nvfuser_direct.
doc/dev/python_scheduling/autotune_inner_reduction.py Adds TODO comment but still imports from removed nvfuser module - script will fail at runtime.
doc/dev/python_scheduling/autotune_matmul.py Adds TODO comment but still imports from removed nvfuser module - script will fail at runtime.
doc/dev/python_scheduling/autotune_pointwise.py Adds TODO comment but still imports from removed nvfuser module - script will fail at runtime.
doc/dev/python_scheduling/profile_matmul.py Adds TODO comment but still imports from removed nvfuser module - script will fail at runtime.
python/python_direct/runtime.cpp Changes LaunchParams default argument to std::optional to avoid creating default LaunchParams at import time. Clean workaround.
python/utils.py Removes nvfuser._C extension module build; keeps nvfuser_direct._C_DIRECT only. Contains a stale include path for python_frontend headers in package_data.
tests/python/direct/test_import.py Removes test_import_conflict_direct_then_nvfuser test that tested legacy nvfuser vs nvfuser_direct import conflict. Keeps test_import_correct for nvfuser_direct.
tools/check_symbol_visibility.sh Removes all nvfuser extension symbol checking, keeping only nvfuser_direct. Clean removal.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph "Before (Removed)"
        A[python/nvfuser/ package] --> B[python_frontend/ C++ bindings]
        B --> C[libnvfuser.so]
        C --> D[libnvfuser_codegen.so]
        E[csrc/serde/fusion_record.cpp] --> B
    end
    subgraph "After (Retained)"
        F[python/nvfuser_direct/ package] --> G[python_direct/ C++ bindings]
        G --> H[libnvfuser_direct.so]
        H --> I[libnvfuser_codegen.so]
        J[python_common/ sources] --> H
    end
    style A fill:#f99,stroke:#c33
    style B fill:#f99,stroke:#c33
    style C fill:#f99,stroke:#c33
    style E fill:#f99,stroke:#c33
    style F fill:#9f9,stroke:#3c3
    style G fill:#9f9,stroke:#3c3
    style H fill:#9f9,stroke:#3c3
    style I fill:#9f9,stroke:#3c3
    style J fill:#9f9,stroke:#3c3
Loading

Last reviewed commit: d21881d

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 3, 2026

Additional Comments (2)

python/utils.py
stale reference to removed python_frontend directory


tools/env-config/env_options.yaml
stale entries for removed debug options python_definition_segments and python_frontend_debug should be removed

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 3, 2026

Additional Comments (1)

python/utils.py
outdated comment references nvfuser._C which was removed in this PR

    # "nvfuser_codegen" into "./nvfuser_direct/lib", and the former will be "nvfuser_direct._C_DIRECT".

@rdspring1 rdspring1 force-pushed the remove_legacy_bindings branch from 7d0a9ba to 904ab90 Compare February 4, 2026 05:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 7 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Additional Comments (7)

tests/python/utils/utils.py
The nvfuser module has been removed in this PR. Update to import from nvfuser_direct instead:

from nvfuser_direct import FusionCache, FusionDefinition, DataType, clone, Tensor

doc/dev/python_scheduling/autotune_utils.py
The nvfuser module has been removed. Update to import from nvfuser_direct:

from nvfuser_direct import FusionCache, FusionDefinition

doc/dev/python_scheduling/autotune_pointwise.py
Update to use nvfuser_direct instead of removed nvfuser module:

from nvfuser_direct import FusionDefinition, SchedulerType, DataType

doc/dev/python_scheduling/autotune_inner_reduction.py
Update to use nvfuser_direct:

from nvfuser_direct import FusionDefinition, SchedulerType, DataType, ParallelType

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


doc/dev/python_scheduling/autotune_persistent.py
Update imports to use nvfuser_direct:

from nvfuser_direct import FusionCache, FusionDefinition, SchedulerType, DataType
from nvfuser_direct.pytorch_utils import torch_dtype_to_nvfuser_dtype

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


doc/dev/python_scheduling/autotune_matmul.py
Update to use nvfuser_direct:

from nvfuser_direct import FusionDefinition, SchedulerType

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


doc/dev/python_scheduling/profile_matmul.py
Update imports to use nvfuser_direct instead of removed nvfuser module

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@rdspring1 rdspring1 force-pushed the remove_legacy_bindings branch from 21cb6bd to 5107f26 Compare February 4, 2026 19:24
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +8 to +9

# TODO Update script to use nvfuser_direct module
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO added but imports still reference removed nvfuser module - script will fail

Suggested change
# TODO Update script to use nvfuser_direct module
# TODO Update script to use nvfuser_direct module
from nvfuser_direct import FusionDefinition, SchedulerType, DataType, ParallelType

Comment on lines +8 to +9

# TODO Update script to use nvfuser_direct module
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO added but imports still reference removed nvfuser module - script will fail

Suggested change
# TODO Update script to use nvfuser_direct module
# TODO Update script to use nvfuser_direct module
from nvfuser_direct import FusionDefinition, SchedulerType

Comment on lines 8 to +9
import math

Copy link
Contributor

Choose a reason for hiding this comment

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

TODO added but imports still reference removed nvfuser module - script will fail

Suggested change
import math
# TODO Update script to use nvfuser_direct module
from nvfuser_direct import FusionDefinition, SchedulerType, DataType

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Additional Comments (3)

doc/dev/python_scheduling/autotune_utils.py
imports from removed nvfuser module will fail at runtime

from nvfuser_direct import FusionCache, FusionDefinition

doc/dev/python_scheduling/autotune_persistent.py
imports from removed nvfuser module will fail at runtime

from nvfuser_direct import FusionCache, FusionDefinition, SchedulerType, DataType
from nvfuser_direct.pytorch_utils import torch_dtype_to_nvfuser_dtype

doc/dev/python_scheduling/profile_matmul.py
TODO added but imports still reference removed nvfuser module - script will fail. All imports need updating to nvfuser_direct

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

import itertools

# TODO Update script to use nvfuser_direct module
from nvfuser import FusionDefinition, SchedulerType, DataType, ParallelType
Copy link
Contributor

Choose a reason for hiding this comment

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

Script imports from removed nvfuser module and will fail at runtime

Suggested change
from nvfuser import FusionDefinition, SchedulerType, DataType, ParallelType
from nvfuser_direct import FusionDefinition, SchedulerType, DataType, ParallelType

@@ -6,6 +6,8 @@
import torch
import itertools
import math
Copy link
Contributor

Choose a reason for hiding this comment

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

Script imports from removed nvfuser module and will fail at runtime

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Additional Comments (2)

doc/dev/python_scheduling/autotune_matmul.py
Script imports from removed nvfuser module and will fail at runtime

from nvfuser_direct import (
    FusionDefinition,
    SchedulerType,
    ClusterDims,
    MatMulTileOptions,
    GemmTile,
    MmaMacroEncode,
    MmaMacroArch,
    MatmulTileRasterizationOrder,

doc/dev/python_scheduling/profile_matmul.py
Script imports from removed nvfuser module and will fail at runtime

from nvfuser_direct import (
    FusionDefinition,
    SchedulerType,
    ClusterDims,
    MatMulTileOptions,
    GemmTile,
    MmaMacroEncode,
    MmaMacroArch,
    MatmulTileRasterizationOrder,
    MatmulCircularBufferingStrategy,
)

@rdspring1 rdspring1 force-pushed the remove_legacy_bindings branch from aa333da to da9c5e0 Compare February 18, 2026 17:06
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

48 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

Choose a reason for hiding this comment

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

Stale reference to removed nvfuser extension

This line references nvfuser_undefined_symbols.txt, but that file is never generated since the check_extension_symbols "$NVFUSER_EXT" "nvfuser" call was removed. Only nvfuser_direct_undefined_symbols.txt is produced now. This should be removed.

Suggested change
echo "- nvfuser_undefined_symbols.txt: Undefined symbols from nvfuser extension"


# NvFuser Serialization

## Serialization is disabled because legacy bindings are removed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Stale documentation referencing removed code

The note on line 9 says serialization is "disabled," but the rest of the document (lines 14–421) still extensively describes FusionCache, RecordFunctor, the Trie structure, and the serde testing process — all of which rely on the now-removed python_frontend code. Consider either removing or archiving the bulk of this file, or at least adding a more prominent deprecation notice explaining which parts are still valid vs. obsolete.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

* LaunchParams is constructed when nvfuser_direct is loaded.
* It uses at::cuda::getCurrentDeviceProperties(), which initializes
Cuda context.
@rdspring1 rdspring1 force-pushed the remove_legacy_bindings branch from da9c5e0 to d21881d Compare February 18, 2026 21:18
@rdspring1
Copy link
Collaborator Author

!test --dev

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

49 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 18, 2026

Additional Comments (1)

python/utils.py
Stale package_data glob for removed directory

This glob pattern references include/nvfuser/python_frontend/*.h, but the entire python_frontend directory and its headers have been removed in this PR. The CMakeLists.txt no longer installs these headers either, so this glob will match nothing. It should be removed to keep the packaging config accurate.

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

Comments