Skip to content

chore: reenable py313 #3455

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 22 commits into from
Apr 17, 2025
Merged

chore: reenable py313 #3455

merged 22 commits into from
Apr 17, 2025

Conversation

zewenli98
Copy link
Collaborator

Description

Reenabled Python 3.13 builds since TensorRT has 3.13 wheels available now for TensorRT 10.9.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@zewenli98 zewenli98 requested a review from lanluo-nvidia March 31, 2025 20:20
@zewenli98 zewenli98 self-assigned this Mar 31, 2025
@zewenli98 zewenli98 marked this pull request as draft March 31, 2025 20:20
@zewenli98 zewenli98 requested a review from narendasan March 31, 2025 21:24
@narendasan narendasan added the ciflow/binaries/all Build for all Python Versions label Mar 31, 2025
Copy link

pytorch-bot bot commented Mar 31, 2025

No ciflow labels are configured for this repo.
For information on how to enable CIFlow bot see this wiki

@narendasan narendasan linked an issue Mar 31, 2025 that may be closed by this pull request
@github-actions github-actions bot added the component: tests Issues re: Tests label Apr 1, 2025
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you don't need to install rust. Instead, you should try to bump the version of transformers in tests/py/requirements.txt. transformers 4.40.2 depended on tokenizers 0.19.x, but tokenizers 0.19.x didn't have wheels for cp313. That's why pip downloaded the source archive of tokenizers and then compiled unsuccessfully.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The updated transformers doesn't match the results of BERT, compared with old transformers and TRT, so we fixed the version here. Any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

The test_bert_base_uncased in test_models and test_models_export was flawed. The inputs were defined as torch.randint(0, 1, ...), which returned a meaningless tensor filled with all zeros because the value of the second arg high is exclusive. To get a useful tensor the high arg should be at least 2, like https://pytorch.org/TensorRT/tutorials/_rendered_examples/dynamo/torch_compile_transformers_example.html.

@zewenli98 zewenli98 force-pushed the reenable_py313 branch 2 times, most recently from 323e177 to 404365a Compare April 1, 2025 19:54
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 3, 2025
@github-actions github-actions bot removed the component: conversion Issues re: Conversion stage label Apr 3, 2025
@github-actions github-actions bot removed component: conversion Issues re: Conversion stage component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 3, 2025
@narendasan narendasan added cherry-pick To cherry-pick to a release branch needs-release-cherrypick labels Apr 4, 2025
@github-actions github-actions bot requested a review from narendasan April 4, 2025 00:35
@narendasan narendasan removed the cherry-pick To cherry-pick to a release branch label Apr 4, 2025
@github-actions github-actions bot added the component: build system Issues re: Build system label Apr 9, 2025
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 11, 2025
@zewenli98 zewenli98 marked this pull request as ready for review April 17, 2025 20:24
Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

LGTM

transformers==4.40.2
nvidia-modelopt[deploy,hf,torch]~=0.17.0
transformers==4.49.0
nvidia-modelopt[deploy,hf,torch]~=0.17.0; python_version < "3.13"
Copy link
Collaborator

Choose a reason for hiding this comment

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

modelopt doesn't support 3.13 yet ? So, quantization also won't work right in Python 3.13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, I think we've already directly skip quantization tests like

@unittest.skipIf(
not importlib.util.find_spec("modelopt"),
"ModelOpt is required to run this test",
)
@pytest.mark.unit
def test_base_fp8(ir):
import modelopt.torch.quantization as mtq
from modelopt.torch.quantization.utils import export_torch_mode
class SimpleNetwork(torch.nn.Module):
def __init__(self):
super(SimpleNetwork, self).__init__()
self.linear1 = torch.nn.Linear(in_features=10, out_features=5)
self.linear2 = torch.nn.Linear(in_features=5, out_features=1)
def forward(self, x):
x = self.linear1(x)
x = torch.nn.ReLU()(x)
x = self.linear2(x)
return x

Users may not be aware of it though

@@ -62,6 +64,22 @@ def not_implemented(*args: List[Any], **kwargs: Dict[str, Any]) -> Any:
return wrapper


def needs_refit(f: Callable[..., Any]) -> Callable[..., Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can make this a bit more generic (like for any feature in the FeatureSet)

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.

Think it mostly looks good, I think we should think about making the requires decorator a bit more generic and unify needs_torch_tensorrt_runtime and needs_refit, maybe something like needs_feature. Maybe something for after 2.7

@zewenli98
Copy link
Collaborator Author

Think it mostly looks good, I think we should think about making the requires decorator a bit more generic and unify needs_torch_tensorrt_runtime and needs_refit, maybe something like needs_feature. Maybe something for after 2.7

sure, will think about it for the next release.

@zewenli98 zewenli98 merged commit 72947c5 into main Apr 17, 2025
461 of 462 checks passed
@zewenli98 zewenli98 mentioned this pull request Apr 18, 2025
7 tasks
zewenli98 added a commit that referenced this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/binaries/all Build for all Python Versions cla signed component: api [Python] Issues re: Python API component: build system Issues re: Build system component: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests needs-release-cherrypick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨[Feature] py3.13 wheels
5 participants