Skip to content

slight code reorg and bug correction for cross_compile #3472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

apbose
Copy link
Collaborator

@apbose apbose commented Apr 14, 2025

Addresses the following for the cross_compile_for_windows feature-

  1. Slight code reorg
  2. replace cross_compile_flag with cross_compile_module
  3. Bug fix for 🐛 [Bug] Wrong output shape from cross compiled exported program #3400

@github-actions github-actions bot added component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 14, 2025
@github-actions github-actions bot requested a review from peri044 April 14, 2025 20:35
@apbose apbose marked this pull request as draft April 14, 2025 20:35
# insert the no_placeholder node in the graph which should be replaced to the actual execute_engine node while load in the windows
trt_node = gm.graph.call_function(
torch.ops.tensorrt.no_op_placeholder_for_execute_engine.default,
(trt_module_node.args, *engine_info),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to unpack this list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We would still need to unpack the list. Else while loading in windows it shows

File "C:\Users\abose\Documents\work\TensorRT\torchTRT\Lib\site-packages\torch\_export\serde\serialize.py", line 2258, in deserialize_inputs
  args.append(actual_args[schema_arg.name])
        ~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'name'

@apbose apbose marked this pull request as ready for review April 15, 2025 21:16
@@ -144,6 +144,7 @@ def no_op_placeholder_for_execute_engine(
serialized_hardware_compatible: str,
serialized_metadata: str,
serialized_target_platform: str,
serialized_require_output_allocator: str,
Copy link
Collaborator

@narendasan narendasan Apr 15, 2025

Choose a reason for hiding this comment

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

Move this placeholder op to runtime/meta_ops

getitem_nodes = trt_node.users
for idx, getitem_node in enumerate(getitem_nodes):
getitem_node.meta["val"] = trt_node.meta["val"][idx]
no_op_placeholder_node.replace_all_uses_with(trt_node)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a multi output testcase to the cross compile tests?

no_op_placeholder_node.replace_all_uses_with(trt_node)
getitem_nodes = trt_node.users
for idx, getitem_node in enumerate(getitem_nodes):
getitem_node.meta["val"] = trt_node.meta["val"][idx]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@narendasan this is the part which should address the bug

@@ -22,6 +22,8 @@ class Add(torch.nn.Module):
def forward(self, a, b):
return torch.add(a, b)

print("here")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this

@apbose apbose force-pushed the cross_compile_code_reorg_and_corr branch from 3f8ab4c to 2934660 Compare April 19, 2025 00:17
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM

@apbose
Copy link
Collaborator Author

apbose commented Apr 21, 2025

@bowang007 on linux converter tests I see-
FAILED automatic_plugin/test_flashinfer_rmsnorm.py::TestAutomaticPlugin::test_rmsnorm_float_0 - RuntimeError: FlashInfer requires sm75+
and on windows I see

error: [WinError 32] The process cannot access the file because it is being used by another process: 'build\\bdist.win-amd64\\wheel\\flashinfer\\data\\cutlass\\include\\cutlass\\experimental\\distributed\\device'

      [end of output]

Would you know what is going wrong?

@bowang007
Copy link
Collaborator

@bowang007 on linux converter tests I see- FAILED automatic_plugin/test_flashinfer_rmsnorm.py::TestAutomaticPlugin::test_rmsnorm_float_0 - RuntimeError: FlashInfer requires sm75+ and on windows I see error: [WinError 32] The process cannot access the file because it is being used by another process: 'build\bdist.win-amd64\wheel\flashinfer\data\cutlass\include\cutlass\experimental\distributed\device'

  [end of output]

Would you know what is going wrong?

Hi @apbose ,

When you do the cross-compile, what is the sm version that you are compiling into?
If flashinfer library is not support on other platform, maybe we could just turn these tests off

@apbose
Copy link
Collaborator Author

apbose commented Apr 21, 2025

Hmm @bowang007 are you suggesting the above wrt to the linux tests or the windows test? The error seems to be coming specifically in pytorch/TensorRT/tree/main/tests/py/dynamo/automatic_plugin/test_flashinfer_rmsnorm.py tests in linux
which is independent of cross compilation. The windows error I am not sure. Am I missing something?

@bowang007
Copy link
Collaborator

wrt

Hi @apbose ,
I mean it is not because of cross-compilation, it is because of the flashinfer library here https://github.com/flashinfer-ai/flashinfer might just not support running on the platform with sm 75 or windows.

@bowang007
Copy link
Collaborator

wrt

Hi @apbose , I mean it is not because of cross-compilation, it is because of the flashinfer library here https://github.com/flashinfer-ai/flashinfer might just not support running on the platform with sm 75 or windows.

@apbose can we do something like turning off these tests for other platforms for now?

@apbose apbose force-pushed the cross_compile_code_reorg_and_corr branch from 2934660 to f8f0f55 Compare April 21, 2025 23:15
@apbose apbose merged commit dc36709 into main Apr 22, 2025
65 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: runtime component: tests Issues re: Tests needs-release-cherrypick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants