Repository navigation
Add unsloth doctor --gpus multi-GPU preflight and UNSLOTH_DEBUG_DISTRIBUTED - #13884
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
… detection, file-backed rank logs, NVML init for driver; set both flight recorder names [skip ci]
…l started ranks when a spawn fails, report a torch that fails to load [skip ci]
…terrupt, require P2P read both ways [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d8a0a8173
ℹ️ 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".
| typer.echo(f"ROCm (HIP) {info['hip']}") | ||
| else: | ||
| typer.echo(f"CUDA (torch build) {info['cuda']}") | ||
| typer.echo(f"driver {driver_version(pynvml) or 'unknown'}") |
There was a problem hiding this comment.
Select the driver probe by GPU backend
When info["hip"] identifies a supported ROCm installation, this still invokes driver_version(), which only queries NVIDIA NVML and nvidia-smi. Consequently an AMD-only host always reports driver unknown, while a mixed AMD/NVIDIA host can report the unrelated NVIDIA driver as though it belongs to the ROCm devices; choose a ROCm-specific query or clearly omit this NVIDIA-only field in that branch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
On ROCm the line already reads "driver unknown" when NVML has nothing to report, which is accurate rather than misleading; a mixed AMD and NVIDIA host is not a configuration torch can use for one training job, so a ROCm-specific driver query adds nothing to the verdict.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6eee289d9
ℹ️ 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".
| if not uuid.startswith(("GPU-", "MIG-")): | ||
| uuid = "GPU-" + uuid | ||
| handles.append(pynvml.nvmlDeviceGetHandleByUUID(uuid.encode())) |
There was a problem hiding this comment.
Resolve bare MIG UUIDs with the MIG prefix
On PyTorch 2.6/2.7 with CUDA MIG devices, the PCI fields are absent and this fallback is used, but str(_CudaDeviceProperties.uuid) is a bare UUID because PyTorch formats the raw CUuuid bytes without retaining the device kind (PyTorch binding). CUDA returns the subscribed MIG instance's UUID in MIG mode, while NVML distinguishes GPU and MIG identifiers (CUDA documentation, NVML documentation); unconditionally prepending GPU- therefore makes nvmlDeviceGetHandleByUUID miss the MIG instance and disables the entire topology table. Match against NVML UUIDs or retry the bare UUID with MIG- before declaring topology unavailable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MIG instances do not support peer-to-peer and are not used for multi-GPU NCCL training, which is what this table is for; on that path the topology section degrades to unavailable without affecting the verdict.
…be crashes, bound rank reaping; debug env: no writes once a process group exists [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…nd FSDP2 launch env hooks)
…-budget metrics across ranks (unslothai#14207) ## Summary Three follow-ups on opt-in features. Default runs are unchanged. 1. **MFU logging (unslothai#13885).** For packed batches that carry only `position_ids`, the token count branched on data, which broke `fullgraph = True` compilation and added a host sync per micro-batch. It is now computed without a data-dependent branch. Also adds an H200 NVL entry at 835.5 dense TFLOPS (half of NVIDIA's 1,671 with-sparsity figure); it was being measured against the H200 SXM peak. 2. **NCCL INFO logs under `UNSLOTH_DEBUG_DISTRIBUTED` (unslothai#13884).** Importing unsloth_zoo sets `NCCL_DEBUG=WARN` whenever a logging or compile-debug switch is on, so the debug flag lost the NCCL INFO logs it asks for. With `UNSLOTH_DEBUG_DISTRIBUTED` set, unsloth now saves `NCCL_DEBUG` before that import and restores it after. 3. **Token-budget split metrics across ranks (unslothai#13878).** Logged accuracy and entropy from split chunks were averaged per rank. Each chunk is now weighted by its token count summed across ranks. The decision to merge is folded into the existing chunk-count collective, so every rank merges or none do: no extra collective and no chance of one rank waiting on another. ## Tests | File | main | this PR | |---|---|---| | `tests/test_mfu_logging.py` | 2 failed | pass | | `tests/test_debug_distributed_env.py` | 2 failed (real zoo import) | pass | | `tests/test_token_budget_metrics_distributed.py` (2 gloo ranks) | 3 failed | pass | 53 passed in total. ## Not covered here - No real multi-rank NCCL run; the distributed tests use gloo. - The H200 NVL device-name string is assumed to contain "H200 NVL". - A `NCCL_DEBUG` you export yourself is still overwritten when the debug flag is off; that needs a change in unsloth_zoo.
Multi-GPU problems on consumer and cloud boxes usually show up as a hang at the first collective, or as silently wrong peer copies on hosts with a translating IOMMU. Today the only tool is
scripts/p2p_integrity_probe.py, which is aimed at llama.cpp and is not part of the installed package. This adds a preflight that answers "will distributed training work on this machine" before a long job starts.unsloth doctor --gpus(alsopython -m unsloth_cli doctor) prints:The exit status is 1 when a problem is found, so it can gate a launch script.
Output on a Kaggle T4x2 (torch 2.14.1, NCCL 2.30.7):
UNSLOTH_DEBUG_DISTRIBUTED=1is a single switch for hang debugging. Atimport unsloth, before any process group exists, it sets TORCH_NCCL_DESYNC_DEBUG=1, TORCH_NCCL_DUMP_ON_TIMEOUT=1, NCCL_DEBUG=INFO and a 2000 entry flight recorder under the name the installed torch reads: TORCH_FR_BUFFER_SIZE on torch 2.8+, TORCH_NCCL_TRACE_BUFFER_SIZE on 2.6 and 2.7 (2.7 defaults the recorder to off). Setting both would make newer torch warn on every rank. Anything the user already set is left alone, and the two buffer names are treated as one setting so an explicit TORCH_NCCL_TRACE_BUFFER_SIZE=0 is respected. Without the flag nothing changes.Tests (CPU):
unsloth_cli/tests/test_doctor_gpus.pyruns a real 2-rank gloo all_reduce, a forced hang, every verdict branch, the NVML pair mapping with a fake pynvml and the full command with a faked 2-GPU torch.tests/test_debug_distributed_env.pycovers the env switch and checks the hook runs before torch is imported.