Skip to content

Fix fbcode import of triton_constexpr_configs in inductor test - #195663

Closed
huydhn wants to merge 1 commit into
gh/huydhn/57/basefrom
gh/huydhn/57/head
Closed

huydhn wants to merge 1 commit into
gh/huydhn/57/basefrom
gh/huydhn/57/head

Conversation

@huydhn

@huydhn huydhn commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Forward fix for D117882973 (#189692), which broke
fbcode//caffe2/test/inductor:codegen_triton at listing time.

That diff added a new helper module triton_constexpr_configs.py next to
test_codegen_triton.py and imported it with two OSS-only fallbacks:

try:
    from triton_constexpr_configs import ...          # test/inductor on sys.path
except ImportError:
    from test.inductor.triton_constexpr_configs import ...   # pytorch repo root on sys.path

The file itself is packaged fine internally -- :inductor_test_lib uses
srcs = glob(["*.py"]), so no BUCK change is needed -- but inside the PAR it
resolves under the fbcode base module as
caffe2.test.inductor.triton_constexpr_configs. Neither branch matches, so
both raised ModuleNotFoundError and the whole module failed to import,
taking down all 22 tests in the suite, not just the new ones:

ModuleNotFoundError: No module named 'triton_constexpr_configs'
During handling of the above exception, another exception occurred:
ModuleNotFoundError: No module named 'test.inductor'

Switch to the relative-first pattern already used elsewhere in this directory
(test_codecache.py, test_ck_backend.py). The relative import resolves
against whatever package the test module actually lives in, so it covers all
three run modes: the fbcode PAR (caffe2.test.inductor), OSS pytest from the
repo root (test.inductor), and python test/inductor/test_codegen_triton.py
(no package, falls through to the bare import).

This also matters beyond the import statement itself. The new
get_importable_constexpr_types emits from {type.__module__} import ...
into the generated Triton kernel source, so the helper module has to be
reachable under its real package name for
test_user_defined_triton_kernel_non_builtin_constexpr to compile and run.

xplat/caffe2 is updated to keep it in sync with fbcode/caffe2.

Differential Revision: D118378564

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195663

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 3165cb2 with merge base 29343e7 (image):
💚 Looks good so far! There are no failures yet. 💚

GREEN LIGHT - PR approved to be merged without human review:

Test-only, two-line import fix in test/inductor/test_codegen_triton.py: the
try/except ImportError block now tries `from .triton_constexpr_configs import
...` first and falls back to the bare `from triton_constexpr_configs import
...`, replacing the `test.inductor.` absolute fallback that could not resolve
inside the fbcode PAR (test/ has no __init__.py, test/inductor/ does). This is
exactly the relative-first pattern already used by sibling tests
test_codecache.py:106 and test_ck_backend.py:14, and it still covers direct
`python test/inductor/test_codegen_triton.py` runs since a relative import with
no parent package raises ImportError and falls through to the bare import; grep
confirms triton_constexpr_configs is referenced nowhere else in the tree.

reason: clean
Reviewed commit: 3165cb2

Inference job

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 2, 2026
@meta-codesync

meta-codesync Bot commented Sep 2, 2026

Copy link
Copy Markdown

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
…ch#195663)

Forward fix for D117882973 (pytorch#189692), which broke
`fbcode//caffe2/test/inductor:codegen_triton` at listing time.

That diff added a new helper module `triton_constexpr_configs.py` next to
`test_codegen_triton.py` and imported it with two OSS-only fallbacks:

```
try:
    from triton_constexpr_configs import ...          # test/inductor on sys.path
except ImportError:
    from test.inductor.triton_constexpr_configs import ...   # pytorch repo root on sys.path
```

The file itself is packaged fine internally -- `:inductor_test_lib` uses
`srcs = glob(["*.py"])`, so no BUCK change is needed -- but inside the PAR it
resolves under the fbcode base module as
`caffe2.test.inductor.triton_constexpr_configs`. Neither branch matches, so
both raised `ModuleNotFoundError` and the whole module failed to import,
taking down all 22 tests in the suite, not just the new ones:

```
ModuleNotFoundError: No module named 'triton_constexpr_configs'
During handling of the above exception, another exception occurred:
ModuleNotFoundError: No module named 'test.inductor'
```

Switch to the relative-first pattern already used elsewhere in this directory
(`test_codecache.py`, `test_ck_backend.py`). The relative import resolves
against whatever package the test module actually lives in, so it covers all
three run modes: the fbcode PAR (`caffe2.test.inductor`), OSS pytest from the
repo root (`test.inductor`), and `python test/inductor/test_codegen_triton.py`
(no package, falls through to the bare import).

This also matters beyond the import statement itself. The new
`get_importable_constexpr_types` emits `from {type.__module__} import ...`
into the generated Triton kernel source, so the helper module has to be
reachable under its real package name for
`test_user_defined_triton_kernel_non_builtin_constexpr` to compile and run.

`xplat/caffe2` is updated to keep it in sync with `fbcode/caffe2`.

Differential Revision: [D118378564](https://our.internmc.facebook.com/intern/diff/D118378564/)

Pull Request resolved: pytorch#195663
Approved by: https://github.com/pytorchgreenlight
@github-actions
github-actions Bot deleted the gh/huydhn/57/head branch November 13, 2026 01:49
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.

2 participants