Functorch or inductor testing is not working locally, main problem is functorch

PyDevC: <p>I have been trying to fix this from three days, retrying with a fresh setup, following every step given in the README.md or CONTRIBUTING.md .</p>
<p>when every I try to run <code>pytest test/inductor/test_compiled_autograd.py</code>, I get this error</p>
<pre><code class="lang-auto">ImportError while importing test module '/home/pydevc/pytorch/test/inductor/test_compiled_autograd.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/inductor/test_compiled_autograd.py:49: in &lt;module&gt;
    from torch.testing._internal.hop_db import hop_db
torch/testing/_internal/hop_db.py:7: in &lt;module&gt;
    from functorch.experimental.control_flow import map
functorch/experimental/__init__.py:2: in &lt;module&gt;
    from functorch import functionalize
E   ImportError: cannot import name 'functionalize' from 'functorch' (unknown location)
=================================================================================== short test summary info ===================================================================================
ERROR test/inductor/test_compiled_autograd.py
</code></pre>
<p>When I tried to run it previously, it worked without any issue.</p>

PyDevC: <p>still not working, does anybody have any idea why?</p>

ptrblck: <p>I cannot reproduce the import error and can properly run the test using the latest nightly (<code>2.9.0.dev20250831+cu129</code>).</p>

PyDevC: <p>I am running latest viable/strict</p>

PyDevC: <p>I checked other tests but they are working. Except for the tests that includes importing functorch</p>

ptrblck: <p>Do you see any issues using any of our binaries or only your source builds?</p>

PyDevC: <p>I haven’t tested with pre-built binaries.<br>
But that won’t do a thing cause I have some code changes that I need to test.</p>
<p>this is the pull request I need to write testcases for <a href="https://github.com/pytorch/pytorch/pull/161266" class="inline-onebox" rel="noopener nofollow ugc">BackwardHookFunction implementation for full_backward_hook in pytorch 2.0 format by PyDevC · Pull Request #161266 · pytorch/pytorch · GitHub</a></p>

PyDevC: <p>I figured that the problem is with my pytest testing environment, cause using python to run test directly works completely fine.</p>
<p>I think the problem is with my own environment</p>

ptrblck: <aside class="quote no-group" data-username="PyDevC" data-post="7" data-topic="222717">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pydevc/48/77306_2.png" class="avatar"> PyDevC:</div>
<blockquote>
<p>But that won’t do a thing cause I have some code changes that I need to test.</p>
</blockquote>
</aside>
<p>The idea is to test different environments and builds to isolate and debug the import error you are seeing.</p>
<aside class="quote no-group" data-username="PyDevC" data-post="8" data-topic="222717">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pydevc/48/77306_2.png" class="avatar"> PyDevC:</div>
<blockquote>
<p>I think the problem is with my own environment</p>
</blockquote>
</aside>
<p>Thanks for confirming!</p>