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

custom function name for "get_custom_dataset" also updates the name of the function called to retreive a custom data loader. #828

Open
1 of 2 tasks
yaoshiang opened this issue Jan 3, 2025 · 0 comments · May be fixed by #829

Comments

@yaoshiang
Copy link

System Info

(llama-dev) azureuser@yh-a100:~/cloudfiles/code/test_llama$ python -m "torch.utils.collect_env"
/anaconda/envs/llama-dev/lib/python3.10/runpy.py:126: RuntimeWarning: 'torch.utils.collect_env' found in sys.modules after import of package 'torch.utils', but prior to execution of 'torch.utils.collect_env'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.28.0
Libc version: glibc-2.31

Python version: 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-1073-azure-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A100 80GB PCIe
Nvidia driver version: 535.183.06
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.5.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
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 24
On-line CPU(s) list: 0-23
Thread(s) per core: 1
Core(s) per socket: 24
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 25
Model: 1
Model name: AMD EPYC 7V13 64-Core Processor
Stepping: 1
CPU MHz: 2445.436
BogoMIPS: 4890.87
Hypervisor vendor: Microsoft
Virtualization type: full
L1d cache: 768 KiB
L1i cache: 768 KiB
L2 cache: 12 MiB
L3 cache: 96 MiB
NUMA node0 CPU(s): 0-23
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 Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Mitigation; safe RET, no microcode
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core invpcid_single vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr rdpru arat umip vaes vpclmulqdq rdpid fsrm

Versions of relevant libraries:
[pip3] flake8==7.1.1
[pip3] flake8-bugbear==24.12.12
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] onnx==1.17.0
[pip3] onnxruntime==1.20.1
[pip3] torch==2.5.1
[pip3] torchvision==0.20.1
[pip3] triton==3.1.0
[conda] numpy 1.26.4 pypi_0 pypi
[conda] torch 2.5.1 pypi_0 pypi
[conda] torchvision 0.20.1 pypi_0 pypi
[conda] triton 3.1.0 pypi_0 pypi

Information

  • The official example scripts
  • My own modified scripts

🐛 Describe the bug

Running the fine tuning script with a custom dataset AND a custom name to replace the default get_custom_dataset using the instructions from the documentation below triggers a bug. The problem is that the string after the colon is used twice: once to find the custom function name to replace get_custom_dataset, and once more find a custom function name for the data collator, replacing the default value of get_data_collator.

To change the function name that is used in the .py you can append the name following a : like this:

python -m llama_recipes.finetuning --dataset "custom_dataset" --custom_dataset.file "custom_dataset.py:get_foo" [TRAINING PARAMETERS]
This will call the function get_foo instead of get_custom_dataset when retrieving the dataset.

Running this script will trigger a log:

set -x

python -m llama_recipes.finetuning \
    --dataset "custom_dataset" \
    --custom_dataset.file "custom_dataset.py:get_custom_dataset" \
    --model_name meta-llama/Llama-3.2-1B-Instruct \
    --use_peft \
    --peft_method lora \
    --num_epochs 1 \
    --max_train_step 2 \
    --max_eval_step 3

Error logs

++ python -m llama_recipes.finetuning --dataset custom_dataset --custom_dataset.file custom_dataset.py:get_custom_dataset --model_name meta-llama/Llama-3.2-1B-Instruct --use_peft --peft_method lora --num_epochs 1 --max_train_step 2 --max_eval_step 3
/mnt/batch/tasks/shared/LS_root/mounts/clusters/yh-a100/code/llama-recipes/src/llama_recipes/model_checkpointing/checkpoint_handler.py:17: DeprecationWarning: `torch.distributed._shard.checkpoint` will be deprecated, use `torch.distributed.checkpoint` instead
  from torch.distributed._shard.checkpoint import (
--> Model meta-llama/Llama-3.2-1B-Instruct

--> meta-llama/Llama-3.2-1B-Instruct has 1235.8144 Million params

trainable params: 851,968 || all params: 1,236,666,368 || trainable%: 0.0689
Parameter 'function'=<function get_custom_dataset.<locals>.<lambda> at 0x7f94d384c700> of the transform datasets.arrow_dataset.Dataset._map_single couldn't be hashed properly, a random hash was used instead. Make sure your transforms and parameters are serializable with pickle or dill for the dataset fingerprinting and caching to work. If you reuse this transform, the caching mechanism will consider it to be different from the previous calls and recompute everything. This warning is only showed once. Subsequent hashing failures won't be showed.
Map: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 9846/9846 [00:00<00:00, 10114.99 examples/s]
Map: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 9846/9846 [00:00<00:00, 23359.21 examples/s]
Map: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████| 44042/44042 [00:01<00:00, 28572.73 examples/s]
Map: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 44042/44042 [00:51<00:00, 858.74 examples/s]
--> Training Set Length = 44042
Map: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 518/518 [00:00<00:00, 13564.99 examples/s]
Map: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 518/518 [00:00<00:00, 21441.96 examples/s]
Map: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 2241/2241 [00:00<00:00, 30807.72 examples/s]
Map: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 2241/2241 [00:02<00:00, 858.85 examples/s]
--> Validation Set Length = 2241
Preprocessing dataset: 100%|███████████████████████████████████████████████████████████████████████████████████████| 44042/44042 [00:15<00:00, 2798.59it/s]
length of dataset_train 3974
Traceback (most recent call last):
  File "/anaconda/envs/llama-dev/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/anaconda/envs/llama-dev/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/yh-a100/code/llama-recipes/src/llama_recipes/finetuning.py", line 428, in <module>
    fire.Fire(main)
  File "/anaconda/envs/llama-dev/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/anaconda/envs/llama-dev/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/anaconda/envs/llama-dev/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/yh-a100/code/llama-recipes/src/llama_recipes/finetuning.py", line 346, in main
    custom_data_collator = get_custom_data_collator(dataset_processer, dataset_config)
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/yh-a100/code/llama-recipes/src/llama_recipes/utils/dataset_utils.py", line 36, in get_custom_data_collator
    return DATALOADER_COLLATE_FUNC[dataset_config.dataset](
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/yh-a100/code/llama-recipes/src/llama_recipes/datasets/custom_dataset.py", line 53, in get_data_collator
    return getattr(module, func_name)(dataset_processer)
TypeError: get_custom_dataset() missing 2 required positional arguments: 'tokenizer' and 'split'

Expected behavior

In a PR, I'll suggest that the custom collator function must always be named get_data_collator. The script should successfully train the model using the custom function name for get_custom_dataset but use the get_data_collator function defined in the custom_dataset.py file, if such a function exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant