Skip to content

Make the cli a top-level package#45181

Draft
tarekziade wants to merge 3 commits intomainfrom
tarekziade-lazy-cli
Draft

Make the cli a top-level package#45181
tarekziade wants to merge 3 commits intomainfrom
tarekziade-lazy-cli

Conversation

@tarekziade
Copy link
Copy Markdown
Collaborator

@tarekziade tarekziade commented Apr 2, 2026

What does this PR do?

The transformers CLI currently does a lot of work before command dispatch. In particular, the top-level entrypoint eagerly imports transformers and CLI subcommands with heavy dependencies, so even simple invocations such as transformers --help are slower than they should be. (up to 5 seconds on my M5)

This PR introduces a lightweight top-level transformers_cli bootstrap package for the public CLI entrypoint. The existing command implementations remain in src/transformers/cli, but the root command no longer has to import the full transformers package just to render top-level help or dispatch subcommands lazily.

This keeps the change narrowly scoped while giving us a cleaner foundation for future CLI work. In particular it becomes easier to add lightweight commands that do not depend on torch-backed transformers internals, and to keep the root CLI path responsive as the command surface grows.

@tarekziade tarekziade requested a review from SunMarc April 2, 2026 08:03
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@tarekziade tarekziade changed the title lazy load for the CLI Make the cli a top-level package Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45181&sha=742f1f

@tarekziade tarekziade marked this pull request as draft April 2, 2026 08:26
@tarekziade tarekziade removed the request for review from SunMarc April 2, 2026 08:29
@tarekziade tarekziade force-pushed the tarekziade-lazy-cli branch from 742f1f9 to 78ac753 Compare April 2, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants