You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "hugolatendresse (via GitHub)" <gi...@apache.org> on 2025/04/19 18:50:31 UTC
[PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
hugolatendresse opened a new pull request, #17863:
URL: https://github.com/apache/tvm/pull/17863
Add support for nn.CrossEntropyLoss in exported program translator.
general_reduction.py would fail when the reduction would reduce to a scalar. This PR allows the last block being a scalar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww merged PR #17863:
URL: https://github.com/apache/tvm/pull/17863
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052367059
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I agree we should avoid exccessive e2e tests and infavor of unit tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on PR #17863:
URL: https://github.com/apache/tvm/pull/17863#issuecomment-2819357703
@mshr-h @tqchen @MasterJH5574 I removed the e2e tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2072693657
##########
tests/python/relax/test_frontend_from_exported_program.py:
##########
@@ -4419,5 +4420,35 @@ def main(
verify_model(Eye2(), example_args2, {}, Expected2)
+def test_cross_entropy():
+ class CrossEntropyModule(Module):
Review Comment:
@mshr-h I added a e2e test case in the nightly tests. Please let me know if that addresses your concern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2055559694
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
Nightly tests are located at tests/python/nightly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2055574818
##########
tests/python/relax/test_frontend_from_exported_program.py:
##########
@@ -4419,5 +4420,35 @@ def main(
verify_model(Eye2(), example_args2, {}, Expected2)
+def test_cross_entropy():
+ class CrossEntropyModule(Module):
Review Comment:
Would be better to include a test case for functional cross entropy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052671383
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
One reason why I added those tests is that we already had support for torch.sort (with a unit test), but when I tested e2e I realized that we had differerent behavior than pytorch. Maybe it's worth it indeed to add those tests to nightly? If so, what is the way to do that?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2072694236
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I moved the e2e tests to nightly in #17907
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052221500
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I'm not confident whether we need e2e tests for every ops.
The upside is we may not have to care about pytorch incompatible API update such as #17680 we hit recently.
The downside is that they increase the CI pressure, which results in a slow development speed.
Maybe nightly is a good place for e2e tests?
cc @Hzfengsy @tqchen @yongwww
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2072693657
##########
tests/python/relax/test_frontend_from_exported_program.py:
##########
@@ -4419,5 +4420,35 @@ def main(
verify_model(Eye2(), example_args2, {}, Expected2)
+def test_cross_entropy():
+ class CrossEntropyModule(Module):
Review Comment:
@mshr-h I added a e2e test case in the nightly tests (last lines of tests/python/nightly/test_nnapi/test_from_exported_to_cuda.py).
Please let me know if that addresses your concern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052221500
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I'm not confident whether we need e2e tests for every ops.
The upside is we don't have to care about pytorch incompatible API update such as #17680 we hit recently.
The downside is that they increase the CI pressure, which results in a slow development speed.
cc @Hzfengsy @tqchen @yongwww
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052221500
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I'm not confident whether we need e2e tests for every ops.
The upside is we may not have to care about pytorch incompatible API update such as #17680 we hit recently.
The downside is that they increase the CI pressure, which results in a slow development speed.
cc @Hzfengsy @tqchen @yongwww
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052367059
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I agree we should avoid exccessive e2e tests and infavor of unit tests, we should move the execution based tests to something likely a nightly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052671383
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
One reason why I added those tests is that we already had support for torch.sort, but when I tested e2e I realized that we had differerent behavior than pytorch. Maybe it's worth it indeed to add those tests to nightly? If so, what is the way to do that?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2052663593
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
Sounds good, I will undo that and also update https://github.com/apache/tvm/pull/17862
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Relax][PyTorch] CrossEntropyLoss [tvm]
Posted by "hugolatendresse (via GitHub)" <gi...@apache.org>.
hugolatendresse commented on code in PR #17863:
URL: https://github.com/apache/tvm/pull/17863#discussion_r2072694236
##########
tests/python/relax/test_from_exported_to_cuda.py:
##########
@@ -588,5 +584,332 @@ def forward(self, x):
assert_torch_output_vs_tvm_from_exported_to_cuda(raw_data, torch_module, target, dev)
+@tvm.testing.parametrize_targets("cuda")
Review Comment:
I moved the e2e tests to nightly in #17907 (the commits are also in this PR to avoid future conflicts)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org