Skip to content

[BACKEND][MTHREADS] Replace monkey-patch with spec_path dynamic lookup#687

Open
Stardep-lmc wants to merge 9 commits into
triton_v3.6.xfrom
feat/mthreads-spec-path-third-party
Open

[BACKEND][MTHREADS] Replace monkey-patch with spec_path dynamic lookup#687
Stardep-lmc wants to merge 9 commits into
triton_v3.6.xfrom
feat/mthreads-spec-path-third-party

Conversation

@Stardep-lmc

Copy link
Copy Markdown
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

@zhzhcookie zhzhcookie Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we spec __init__.py ?
Try from triton.language import squeeze
Or from triton.language import * , then call squeeze

Comment thread third_party/mthreads/backend/spec/triton/runtime/__init__.py Outdated
Comment thread third_party/mthreads/python/triton/runtime/adjust_kernel_param.py
Comment thread third_party/mthreads/backend/spec/triton/runtime/errors.py Outdated
- 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
@Stardep-lmc Stardep-lmc force-pushed the feat/mthreads-spec-path-third-party branch from 048318c to 64f9b09 Compare June 16, 2026 10:59
flagtree-bot and others added 8 commits June 16, 2026 11:01
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants