Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some testing from me #407

Open
ad8e opened this issue Jun 17, 2024 · 3 comments
Open

Some testing from me #407

ad8e opened this issue Jun 17, 2024 · 3 comments

Comments

@ad8e
Copy link

ad8e commented Jun 17, 2024

I tried torchtitan. Here's a grab bag of issues. My setup is CoreWeave-provided PyTorch nightly image, on a CW-hosted HGX in slurm. PyTorch and torchtitan builds are nightlies from a few days ago.

Build information

PyTorch version: 2.4.0a0+d71f922
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.29.5
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.3-coreweave-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3
GPU 2: NVIDIA H100 80GB HBM3
GPU 3: NVIDIA H100 80GB HBM3
GPU 4: NVIDIA H100 80GB HBM3
GPU 5: NVIDIA H100 80GB HBM3
GPU 6: NVIDIA H100 80GB HBM3
GPU 7: NVIDIA H100 80GB HBM3

Nvidia driver version: 535.161.07
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             128
On-line CPU(s) list:                0-127
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8462Y+
CPU family:                         6
Model:                              143
Thread(s) per core:                 2
Core(s) per socket:                 32
Socket(s):                          2
Stepping:                           8
CPU max MHz:                        4100.0000
CPU min MHz:                        800.0000
BogoMIPS:                           5600.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req hfi vnmi avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr ibt amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          3 MiB (64 instances)
L1i cache:                          2 MiB (64 instances)
L2 cache:                           128 MiB (64 instances)
L3 cache:                           120 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-31,64-95
NUMA node1 CPU(s):                  32-63,96-127
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced / Automatic IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.4.0a0+d71f922
[pip3] torchaudio==2.4.0a0+b829e93
[pip3] torchdata==0.7.1.dev20240614+cpu
[pip3] torchvision==0.19.0a0+f96c42f
[pip3] triton==3.0.0
[conda] Could not collect

This PyTorch nightly does not work with my own codebase; the loss is a flat line. However, torchtitan does not experience this issue, and is able to train. (I tried PyTorch nightly 7 times over a few months, but it failed from a different issue each time, so this isn't unusual.)

Using the c4 dataset doesn't work. Using c4_mini does.

Error message with c4

[rank5]: Traceback (most recent call last):
[rank5]:   File "/clusterstorage/workspace/kevin/torchtitan/train.py", line 440, in <module>
[rank5]:     main(config)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 348, in wrapper
[rank5]:     return f(*args, **kwargs)
[rank5]:   File "/clusterstorage/workspace/kevin/torchtitan/train.py", line 161, in main
[rank5]:     data_loader = build_hf_data_loader(
[rank5]:   File "/clusterstorage/workspace/kevin/torchtitan/torchtitan/datasets/hf_datasets.py", line 207, in build_hf_data_loader
[rank5]:     hf_ds = HuggingFaceDataset(
[rank5]:   File "/clusterstorage/workspace/kevin/torchtitan/torchtitan/datasets/hf_datasets.py", line 101, in __init__
[rank5]:     ds = load_dataset(dataset_path, name="en", split="train", streaming=True)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/load.py", line 2594, in load_dataset
[rank5]:     builder_instance = load_dataset_builder(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/load.py", line 2266, in load_dataset_builder
[rank5]:     dataset_module = dataset_module_factory(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/load.py", line 1914, in dataset_module_factory
[rank5]:     raise e1 from None
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/load.py", line 1896, in dataset_module_factory
[rank5]:     ).get_module()
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/load.py", line 1270, in get_module
[rank5]:     data_files = DataFilesDict.from_patterns(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/data_files.py", line 721, in from_patterns
[rank5]:     else DataFilesList.from_patterns(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/data_files.py", line 634, in from_patterns
[rank5]:     origin_metadata = _get_origin_metadata(data_files, download_config=download_config)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/data_files.py", line 548, in _get_origin_metadata
[rank5]:     return thread_map(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/tqdm/contrib/concurrent.py", line 69, in thread_map
[rank5]:     return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/tqdm/contrib/concurrent.py", line 51, in _executor_map
[rank5]:     return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize), **kwargs))
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/tqdm/std.py", line 1169, in __iter__
[rank5]:     for obj in iterable:
[rank5]:   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
[rank5]:     yield _result_or_cancel(fs.pop())
[rank5]:   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
[rank5]:     return fut.result(timeout)
[rank5]:   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
[rank5]:     return self.__get_result()
[rank5]:   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
[rank5]:     raise self._exception
[rank5]:   File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
[rank5]:     result = self.fn(*self.args, **self.kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/datasets/data_files.py", line 527, in _get_single_origin_metadata
[rank5]:     resolved_path = fs.resolve_path(data_file)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_file_system.py", line 179, in resolve_path
[rank5]:     repo_and_revision_exist, err = self._repo_and_revision_exist(repo_type, repo_id, revision)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_file_system.py", line 127, in _repo_and_revision_exist
[rank5]:     self._api.repo_info(repo_id, revision=revision, repo_type=repo_type, timeout=HF_HUB_ETAG_TIMEOUT)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
[rank5]:     return fn(*args, **kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py", line 2491, in repo_info
[rank5]:     return method(
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
[rank5]:     return fn(*args, **kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py", line 2363, in dataset_info
[rank5]:     r = get_session().get(path, headers=headers, timeout=timeout, params=params)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 602, in get
[rank5]:     return self.request("GET", url, **kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 589, in request
[rank5]:     resp = self.send(prep, **send_kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 703, in send
[rank5]:     r = adapter.send(request, **kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_http.py", line 66, in send
[rank5]:     return super().send(request, *args, **kwargs)
[rank5]:   File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 713, in send
[rank5]:     raise ReadTimeout(e, request=request)
[rank5]: requests.exceptions.ReadTimeout: (ReadTimeoutError("HTTPSConnectionPool(host='huggingface.co', port=443): Read timed out. (read timeout=10)"), '(Request ID: 145b9598-b155-4312-b59f-587e763b622a)')

For my final run, I changed these in the llama3 8B config:

enable_profiling = false
enable_tensorboard = false
flavor = "debugmodel"
compile = true
dataset = "c4_mini"
mode = 'full'  # ['none', 'selective', 'full']

Here's the slurm script I used, a merge of torchtitan's multinode_trainer.slurm and CoreWeave's slurm script:
multinode_trainer.txt
Some changes were important on my setup, but I'm not sure which ones matter or would cause problems. rdzv_endpoint=localhost:0 was needed, and so was disabling the dcgmi calls. I understand almost nothing about the changes I made to this slurm script. It runs on one HGX (8 H100s).

Here's the output log: torchtitan_multi_node5645.txt

Observations:

  1. Every single rank prints its own copy of the output. Maybe this is something I'm doing wrong.
  2. The steps are out of order, such as 980 before 810. I could serialize them with PYTHONUNBUFFERED=1, but this seems like a bad idea. This may be a reason for why (3) is happening.
  3. The MFU is 1%. This is the debug model. Maybe that's expected.
  4. The run OOMs, on the debug model. There appears to be a memory leak, since an H100 has 80 GB memory, and the OOM only happens after many steps have passed (although be wary of (2)).
  5. If I switch from the debug model to flavor = "8B", then ranks 1-7 OOM, but root rank 0 trains properly after the slew of error messages: 2024-06-17 04:57:31,148 - root - INFO - step: 40 loss: 7.3387 memory: 41.62GiB(52.61%) wps: 6,268 mfu: 36.71%. (It's with full-AC, remember the config change above.)
  6. If in the 8B model, I switch tocompile = false, then the root rank 0 also crashes so I can't see any mfu numbers. (In my own codebase, torch.compile on/off causes no change in TFLOPS when activation checkpointing is active, which is the issue I was hoping to investigate using torchtitan.)
@tianyu-l
Copy link
Contributor

@ad8e

Using the c4 dataset doesn't work. Using c4_mini does.

This might be because internet access is not available? c4_mini is in the repo, whereas for c4 it tries to download from HF website.

Every single rank prints its own copy of the output.

You can try this

The steps are out of order, such as 980 before 810.

This shouldn't be the case for steps on the same rank.

The MFU is 1%.

This seems OK.

For issue 4, 5, 6, I'm not sure what's going on. I wonder if @lessw2020 has any insights with these slurm jobs.

@ad8e
Copy link
Author

ad8e commented Jun 25, 2024

This might be because internet access is not available? c4_mini is in the repo, whereas for c4 it tries to download from HF website.

The node has connection to the internet, since it's able to log things to the wandb cloud (at least, rank 0 is). I don't think it was a blip in connection, since I tried it a few times over 12 hours. My cluster is full so I can't test it at the moment. It could be some random HF issue, in which case it's somebody else's problem.

You can try this

The trick used in our internal codebase is:

def print_rank0(*args, **kwargs):
    if not torch.distributed.is_initialized() or torch.distributed.get_rank() == 0:
        print(*args, **kwargs)

Information is logged only once with print_rank0, but errors are logged using print. This catches errors on other ranks.

@ad8e
Copy link
Author

ad8e commented Jun 25, 2024

C4 HuggingFace issues are related to multi-GPU jobs in some way.

Single GPU, works: torchtitan_multi_node5885.txt

Multi GPU, errors: torchtitan_multi_node5886.txt

I don't personally care about this HF issue, so it's up to you if fixing it is worth anyone's time.

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

No branches or pull requests

2 participants