Skip to content

Build miles as a pure wheel that imports FSDP and torchtitan without Megatron - #4308

Open
HJSang wants to merge 6 commits into
mainfrom
hjsang/pip-wheel
Open

HJSang wants to merge 6 commits into
mainfrom
hjsang/pip-wheel

Conversation

@HJSang

@HJSang HJSang commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Stack (merge in order): #4308 → #4315 → #4316 → #4311 (needs radixark/miles-wheels#4).

First step toward pip install miles for the FSDP and torchtitan backends, without Megatron.

Changes

  • Pure wheel. Drop the custom bdist_wheel that tagged a pure-Python package cp3X-cp3X-manylinux*; it now builds one py3-none-any wheel.
  • Ship what was missing. The fixed chat templates (templates/*.jinja, read from beside the module) go in package_data. MANIFEST.in adds requirements.txt, without which the sdist could not build.
  • torchtitan extra. torchtitan==0.3.0 (the commit the image pins) plus torch>=2.13, which 0.3.0 needs but does not declare.
  • wheel-smoke workflow + tests/ci/wheel_smoke.py: build the sdist and wheel, install wheel[torchtitan] into a clean venv, hide Megatron / mbridge / TransformerEngine / apex, then import train.py, train_async.py, both backend actors, and the modules loaded by name at run time (the default rollout function, the session server), and parse their args.
  • .github/actions/resolve-dependency-refs. The CPU and CUDA workflows carried identical inline copies of the ci-sglang-pr: / release-lock.json / branch-default resolution. All three jobs now share one action. Both local actions (this one and install-megatron-bridge) load from github.sha so /rerun-test on an older PR head and release CI on an existing branch still find it.

Testing

Not in this PR

🤖 Generated with Claude Code

@HJSang

HJSang commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

@claude review always

@HJSang

HJSang commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T17:09:30.413760Z 1b10595 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.

@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: 1b1059589b

ℹ️ 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 thread .github/workflows/wheel-smoke.yml Outdated
Comment on lines +33 to +36
if [ -f release-lock.json ]; then
ref=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_commit'])")
else
ref=sglang-miles

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 Honor the PR's SGLang override

When a coordinated Miles/SGLang change declares ci-sglang-pr: in the PR body, the existing CPU and CUDA workflows resolve that override before the release lock or branch default, but this new workflow always chooses only release-lock.json or sglang-miles. The wheel check therefore tests a different SGLang tree from the rest of CI and can either block a valid coordinated change or pass against code the PR does not target; reuse the canonical dependency-ref resolution here. .claude/rules/single-source-of-truth.mdL5-L6

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 8768466. Thanks, nice catch.

@claude claude 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.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread .github/workflows/wheel-smoke.yml Outdated
Comment thread tests/ci/wheel_smoke.py Outdated

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@HJSang

HJSang commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

@claude review

Comment thread .github/workflows/_run-ci.yml Outdated

@claude claude 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.

Code review found no issues

No high-confidence issues detected in this change.

@HJSang HJSang changed the title Build Miles as a pure wheel and check FSDP/torchtitan run without Megatron Build miles as a pure wheel that imports FSDP and torchtitan without Megatron Oct 22, 2026

@claude claude 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.

No new blocking issues. 1 optional suggestion (a nit or a note on pre-existing code) was found and not posted. Nothing in this review needs a push before merging.

@claude claude 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.

Code review found no issues

No high-confidence issues detected in this change.

HJSang and others added 5 commits October 27, 2026 10:43
…hout Megatron

The wheel was tagged per interpreter and platform (cp312-cp312-manylinux1_x86_64) although
Miles has no compiled code in it, so it is now a single py3-none-any wheel. The fixed chat
templates that tito_tokenizer reads from next to the module were missing from the wheel, and
the sdist could not build because it lacked requirements.txt; both now ship.

The torchtitan extra installs the 0.3.0 release the Docker image pins by commit, with the
torch>=2.13 floor validate_torchtitan_args already enforces at runtime.

The wheel-smoke workflow installs the built wheel into a clean environment and runs
tests/ci/wheel_smoke.py, which blocks Megatron, mbridge, TransformerEngine and apex on import,
loads train.py and train_async.py, imports both backend actors and parses arguments for each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wheel-smoke picked only release-lock.json or sglang-miles, so a PR pairing with an SGLang PR
through ci-sglang-pr: would smoke against the wrong tree. The resolution block the CPU and CUDA
jobs carried as identical inline copies is now the resolve-dependency-refs action, and all three
jobs use it.

wheel_smoke.py now hides Megatron by setting sys.modules entries to None instead of a raising
meta-path finder, so importlib.util.find_spec probes return None as they would for a package
that is really absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub loads a local action from the checked-out tree, and the reusable CI
workflows check out inputs.ref, which can predate the action: /rerun-test on
an older PR head, or release CI on an existing release branch. Both now check
out .github/actions at github.sha, the commit the workflow runs from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reasons they carried are in the PR description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he workflow's commit

wheel_smoke imported the drivers and actors, but the default rollout function
and the session server are loaded by name at run time. install-megatron-bridge
had the same old-ref problem as resolve-dependency-refs.

Found by an adversarial review of this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread tests/ci/wheel_smoke.py
MEGATRON_ONLY = ("megatron", "mbridge", "transformer_engine", "apex")
BACKENDS = ("fsdp", "torchtitan")
# loaded by name at run time, so importing the drivers does not reach them
RUNTIME_MODULES = ("miles.rollout.sglang_rollout", "miles.rollout.session.server")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cc cmt

[P2] RUNTIME_MODULES checks the legacy rollout, not the default one. miles.rollout.sglang_rollout is selected only when MILES_USE_LEGACY_ROLLOUT_V1=1 (resolve_rollout_function_paths in miles/utils/arguments.py). The default is InferenceRolloutFn, which imports inference_rollout_train inside _call_train and inference_rollout_eval inside _call_eval, so this smoke never imports either module. Nothing on that path imports Megatron at import time today, so this is a missing guard rather than a current crash. Impact: if a Megatron-only import lands in the default train or eval rollout path, wheel-smoke stays green and a wheel install fails at its first rollout. It also contradicts the PR body, which says the smoke covers "the default rollout function".

Suggested fix:

RUNTIME_MODULES = (
    "miles.rollout.inference_rollout.inference_rollout_train",
    "miles.rollout.inference_rollout.inference_rollout_eval",
    "miles.rollout.session.server",
)

Keep miles.rollout.sglang_rollout too if the legacy v1 path should stay covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude 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.

Code review found no issues

No high-confidence issues detected in this change.

@guapisolo guapisolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cc cmt

Approving #4308 at e6ded55. The review ran at 319eb84; the rebase onto main keeps those five commits unchanged, and the new commit raises python_requires to 3.11.

  • [P2] Still open, not blocking: tests/ci/wheel_smoke.py imports the legacy miles.rollout.sglang_rollout rather than the default inference_rollout_train / inference_rollout_eval, so a Megatron-only import added to the default rollout path would keep wheel-smoke green and fail a wheel install at its first rollout. Nothing on that path imports Megatron today. Details and a 3-line fix: #4308 (comment). It can land here or in a follow-up.

Verification: read-only review of this increment at 319eb84 (native review, a Codex cross-harness review, a code-quality check), a range-diff to this head, and a read of the new commit; wheel-smoke is green at this head. Not covered: training from the wheel alone.

This branch has not been deployed

No deployments
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.

3 participants