[BACKEND][MTHREADS] Replace monkey-patch with spec_path dynamic lookup#687
Open
Stardep-lmc wants to merge 9 commits into
Open
[BACKEND][MTHREADS] Replace monkey-patch with spec_path dynamic lookup#687Stardep-lmc wants to merge 9 commits into
Stardep-lmc wants to merge 9 commits into
Conversation
Stardep-lmc
commented
Jun 10, 2026
Collaborator
- Move 48 mthreads-specialized python files from third_party/mthreads/python/triton/ to third_party/mthreads/backend/spec/triton/ (only files that differ from main)
- Add spec_path(path) to triton/init.py, runtime/, compiler/, language/, tools/ for runtime path specialization via flagtree_spec.py
- Remove monkey-patch code from mthreads.py, keep build-time package merging logic and expose apply_mthreads_setup_args()
- Update setup.py to call apply_mthreads_setup_args for non-editable installs when FLAGTREE_BACKEND=mthreads
af6d076 to
57c010b
Compare
zhzhcookie
reviewed
Jun 13, 2026
Collaborator
There was a problem hiding this comment.
Can we spec __init__.py ?
Try from triton.language import squeeze
Or from triton.language import * , then call squeeze
zhzhcookie
reviewed
Jun 13, 2026
zhzhcookie
reviewed
Jun 13, 2026
zhzhcookie
reviewed
Jun 13, 2026
- git mv 12 files with genuine mthreads-specific changes from third_party/mthreads/python/triton/ to backend/spec/triton/ - Add spec_path(__path__) to triton/, compiler/, runtime/, language/, tools/ __init__.py for runtime path specialization - Add max_shared_mem to main compiler/__init__.py and triton/__init__.py - Remove monkey-patch code from mthreads.py (_wrap_setup, _patch_setup_for_mthreads_python_root), keep build-time package merging logic and expose apply_mthreads_setup_args() - Update setup.py to call apply_mthreads_setup_args for non-editable installs when FLAGTREE_BACKEND=mthreads
048318c to
64f9b09
Compare
- Remove runtime/adjust_kernel_param.py (just an older upstream version) - Remove experimental/gluon/__init__.py (missing spec_path setup from upstream) - Restore both files to third_party/mthreads/python/triton/
…only - Remove merge_mthreads_packages, merge_mthreads_package_dir, patch_mthreads_cmdclass, and apply_mthreads_setup_args - get_package_dir() now returns empty dict (no root package override) - Remove apply_mthreads_setup_args call from setup.py - Both editable and non-editable installs now use the standard spec_path mechanism via backends/mthreads/spec/triton/
…/__init__.py - git mv language/core.py and language/standard.py to spec (have mthreads-specific functions: squeeze, unsqueeze, to_tensor, _experimental_descriptor_load, _experimental_descriptor_store) - Add these symbols to main python/triton/language/__init__.py imports and __all__ - Remove async_task import (not in mthreads version) - Revert setup.py to direct setup() call (no intermediate variable)
Spec core.py imports _tuple_create from triton._utils. The mthreads _utils.py has apply_with_path, is_iterable, and _tuple_create that are not in the main version.
Spec core.py is missing upstream async_task, causing ImportError. These files have too much upstream divergence to spec cleanly. Instead, mthreads-specific additions will be merged to main files.
- Add squeeze and unsqueeze functions to python/triton/language/standard.py (mthreads-specific functions now merged to main) - Remove async_task, _experimental_descriptor_load, _experimental_descriptor_store from language/__init__.py (not in main core.py)
…_init__.py - Revert squeeze/unsqueeze from standard.py (stay in mthreads fork) - Revert _experimental_descriptor_* from core.py (stay in mthreads fork) - Keep only spec_path(__path__) in language/__init__.py - Restore language/__init__.py imports to match main upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.