Skip to content

Studio: install the S3 SDK on demand - #14157

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
AlbertoLMa:shrink-install-size
Oct 19, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
AlbertoLMa:shrink-install-size

Conversation

@AlbertoLMa

@AlbertoLMa AlbertoLMa commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Studio currently installs the AWS SDK for every user, although only S3 dataset loading needs it. Move boto3 into an optional s3 extra and install the SDK automatically on the first S3 training request or dataset download. After uv/pip finishes, invalidate import caches and import boto3 in the running Python process; training continues without a restart.

The API runs installation in a worker thread. A file lock serializes installers across threads and processes, and a 40-second total lock/install budget fits within the UI’s 60-second training-start timeout. All installed distribution versions are constrained so the resolver cannot upgrade shared packages. Installer subprocesses receive TLS/proxy settings but not AWS/HF credentials or package-source/target environment overrides. Existing SDK installations are reused. Offline mode, UNSLOTH_S3_AUTO_INSTALL=0, and installation failures provide guidance to preinstall with python -m pip install "unsloth[s3]" using Studio’s interpreter.

Measured default Studio dependency files on macOS arm64 / Python 3.12.2 decrease from 474,868,666 to 452,872,608 bytes, saving 20.98 MiB (4.63%) before S3 is used. Only boto3, botocore, s3transfer, and jmespath disappear; retained distributions have identical versions and file sizes. This measures dependency files, excluding bytecode, the project wheel, test/installer tooling, GPU/ML extras, and model caches. First S3 use downloads the SDK later.

Validation:

  • 175 passed in the SDK-absent environment: installer, S3 behavior, training-route regressions, startup import, and packaging/install tests.
  • 93 passed with the SDK installed: installer, S3, and training-route tests.
  • Real first-use installations through both uv and pip imported boto3 in-process, left existing package versions unchanged, reused the SDK on the second call, and constructed a client with stubbed AWS responses.
  • A built-wheel API check confirmed startup and non-S3 requests install nothing, then the first S3 request installs the SDK and continues without a restart.
  • Two real processes sharing an environment ran exactly one installer subprocess.
  • Tests cover opt-out/offline behavior, failed downloads, timeouts including lock contention, credential filtering, and preventing installation on non-S3 requests. Ruff and git diff --check pass.

Live AWS remains unverified because the available credentials were rejected. Native Linux/Windows and full GPU execution were not tested.

@AlbertoLMa AlbertoLMa changed the title Studio: make S3 dataset dependencies optional Studio: install the S3 SDK on demand Oct 19, 2026
@danielhanchen danielhanchen self-assigned this Oct 19, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T07:00:41.338827Z 33141f4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f38d20ee8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +70
from utils.mlx_repair import _uv_executable
return _uv_executable()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Find uv.exe when Windows keeps uv off PATH

On Windows when uv is installed but not on the inherited PATH (for example, the supported UV_NO_MODIFY_PATH/fresh GUI-process case), this delegates to _uv_executable(), whose fallback probes .local/bin/uv rather than .local/bin/uv.exe; studio/setup.ps1:7987-8017 explicitly handles this case by searching for uv.exe. Since Studio's uv-created venv normally has no pip (studio/install_python_stack.py:4966-4970), _find_uv() then selects the unusable pip fallback and first-use S3 installation returns 501 even though uv is present. Include the Windows executable suffix/install locations in this lookup.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 33141f4: the shared uv locator now probes uv.exe under .local/bin and .cargo/bin on Windows.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 33141f44d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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