Repository navigation
fix(fla): disable intracard CP for single-process launches - #10850
Souravrajvi0 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51fc013acc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if int(os.environ.get("WORLD_SIZE", "1") or 1) <= 1: | ||
| os.environ.setdefault("FLA_DISABLE_BACKEND_DISPATCH", "1") |
There was a problem hiding this comment.
Preserve dispatch for MPI-launched multi-rank jobs
When a multi-rank job is launched through Open MPI, Intel/MPICH, or MVAPICH, the rank count is exposed through variables such as OMPI_COMM_WORLD_SIZE, PMI_SIZE, or MV2_COMM_WORLD_SIZE, while WORLD_SIZE remains unset; the repository explicitly documents these launch modes in studio/backend/core/training/dataset_bounds.py:30-38. Every rank therefore takes this branch and disables FLA backend dispatch, preventing an FLA context-parallel operation from selecting its distributed backend and causing it to run through the non-CP path. Determine single-process status using all supported launcher variables rather than WORLD_SIZE alone.
Useful? React with 👍 / 👎.
|
|
||
| # fla backend dispatch walks registered backends on every hot kernel call; the CP | ||
| # backend rejects single-process training. Set before fla is imported (Qwen3.5 / Next). | ||
| if int(os.environ.get("WORLD_SIZE", "1") or 1) <= 1: |
There was a problem hiding this comment.
Parse WORLD_SIZE without aborting package import
If WORLD_SIZE contains a non-integer value such as auto or another stale launcher setting, this top-level int() raises ValueError before any of Unsloth's import setup runs, so even workflows that do not use FLA can no longer import the package. Other world-size handling in the repository treats unusable values as single-process defaults; this import-time check should likewise fall back safely instead of making an optional optimization fatal.
Useful? React with 👍 / 👎.
|
Setting FLA_DISABLE_BACKEND_DISPATCH process-wide in unsloth/init.py short-circuits the whole dispatch decorator, including the TileLang backend fla turns on by default on sm90+ as a hardware workaround, so could you scope it to the context-parallel backend and confirm a single-GPU Hopper run is unchanged? The branch also carries the Studio llama-server logging and debug log source changes, which are unrelated to the title and would be much easier to review as their own PR. |
|
@danielhanchen Addressed the review on the latest push: Scope: Removed World size: Uses new torch-free Tests: Happy to run a single-GPU Hopper sanity check if you want a specific model/script pinned in CI. |
943156b to
a40d3dd
Compare
|
Thanks for narrowing this to FLA_INTRACARD_CP and dropping the Studio logging commits, that addresses my earlier point; note that unsloth_zoo already sets FLA_INTRACARD_CP=0 and forces IntraCardCPBackend.is_available to False around the vendored fla injection in temporary_patches/fla_vendor.py, so the remaining gap is a separately installed newer fla. Could you confirm that case is what you hit, and if so whether an 81 line launcher world size module with MLX rank file parsing is needed here rather than a plain single process check? |
Drop FLA_DISABLE_BACKEND_DISPATCH so TileLang backend dispatch stays enabled on Hopper. Use launcher_world_size_from_env (MPI + torchrun vars, safe int parsing) and set FLA_INTRACARD_CP=0 before FLA import when the advertised rank count is 1. Removes unrelated Studio llama-server logging commits from this branch.
|
@danielhanchen — Yes: the failure mode was a separately installed World size vs plain single-process: That said, the 81-line MLX rank-file parser was more than this import hook needs. Latest push drops rank-file parsing and keeps the shared env-var max (~40 lines), with a note that FLA training is torch/GPU and multi-rank launchers should already export one of those vars. Still only |
dfffa31 to
bb06b8e
Compare
|
Thank you for the PR and for narrowing it after the earlier review. After checking against upstream flash-linear-attention and unsloth-zoo, I am going to close this one, since
If you do have a reproduction (fla version, script, and the failure or wrong output you saw), please open an issue with it and we can take another look. |
Summary
Single-process Unsloth training (Qwen3.5 / GatedDeltaNet / FLA) should not route through the intra-card context-parallel FLA backend. This PR sets
FLA_INTRACARD_CP=0before FLA is imported when the launcher advertises one data-parallel rank.Does not set
FLA_DISABLE_BACKEND_DISPATCH, so TileLang backend dispatch on sm90+ Hopper stays enabled (per review on #10850).World size
Uses torch-free
unsloth/launcher_world_size.py(same rules as Studiodataset_bounds.world_size_from_env):WORLD_SIZE, MPI vars (OMPI_COMM_WORLD_SIZE,PMI_SIZE,MV2_COMM_WORLD_SIZE, …), and MLX rank files. Invalid values (e.g.auto) fall back to 1 without breakingimport unsloth.Test plan
pytest tests/test_launcher_world_size.pyNotes
Unrelated Studio llama-server logging changes were removed from this branch; they can land in a separate PR.