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

Missing input_ids Error When Going through Llama 3.2 Vision Models Fine-Tuning Recipe #812

Open
1 of 2 tasks
clankur opened this issue Dec 10, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@clankur
Copy link

clankur commented Dec 10, 2024

System Info

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 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.5.119
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 535.183.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.2.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.2.1
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: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
CPU family: 6
Model: 94
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 3
CPU max MHz: 4200.0000
CPU min MHz: 800.0000
BogoMIPS: 7999.96
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 pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 128 KiB (4 instances)
L1i cache: 128 KiB (4 instances)
L2 cache: 1 MiB (4 instances)
L3 cache: 8 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-7
Vulnerability Gather data sampling: Vulnerable: No microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; IBRS
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; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Mitigation; Microcode
Vulnerability Tsx async abort: Mitigation; TSX disabled

Versions of relevant libraries:
[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] No relevant packages

Information

  • The official example scripts
  • My own modified scripts

🐛 Describe the bug

I was following the guide for finetuning vision models on my RTX 4090. However, when I run the following command:

FSDP_CPU_RAM_EFFICIENT_LOADING=1 python finetuning.py \
--use_peft \
--peft_method lora \
--quantization 8bit \
--model_name meta-llama/Llama-3.2-1B \
--output_dir /tmp/ \
--batch_size_training 1 \
--dataset "custom_dataset" \
--custom_dataset.test_split "test" \
--custom_dataset.file "./datasets/ocrvqa_dataset.py" \
--batching_strategy padding

I encounter the following error about missing input_ids:

Traceback (most recent call last):
  File "/home/clankur/dev/ai_space/llama-recipes/recipes/quickstart/finetuning/finetuning.py", line 8, in <module>
    fire.Fire(main)
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/finetuning.py", line 338, in main
    dataset_train = ConcatDataset(
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/data/concatenator.py", line 27, in __init__
    buffer = {k: v + sample[k] for k,v in buffer.items()}
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/data/concatenator.py", line 27, in <dictcomp>
    buffer = {k: v + sample[k] for k,v in buffer.items()}
KeyError: 'input_ids'

Root Cause Analysis

Looking at the code in ocrvqa_dataset.py it seems like there’s missing logic to properly map or preprocess the dataset. This results in an error when the ConcatDataset logic in finetuning.py tries to access input_ids.

Workaround

I was able to get my custom finetuning working by modifying get_custom_dataset to include preprocessing logic similar to what is done in get_preprocessed_samsum for the samsum_dataset. Adding a function like tokenize_add_label seems to resolve the issue.

Suggested Fix

It might be helpful to update the implementation of ocrvqa_dataset to include preprocessing logic to handle tokenization and labels. This would ensure compatibility with the existing dataset concatenation logic.

Error logs

Traceback (most recent call last):
  File "/home/clankur/dev/ai_space/llama-recipes/recipes/quickstart/finetuning/finetuning.py", line 8, in <module>
    fire.Fire(main)
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/clankur/.local/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/finetuning.py", line 338, in main
    dataset_train = ConcatDataset(
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/data/concatenator.py", line 27, in __init__
    buffer = {k: v + sample[k] for k,v in buffer.items()}
  File "/home/clankur/dev/ai_space/llama-recipes/src/llama_recipes/data/concatenator.py", line 27, in <dictcomp>
    buffer = {k: v + sample[k] for k,v in buffer.items()}
KeyError: 'input_ids'

Expected behavior

The finetuning script should process the ocrvqa_dataset without errors, with input_ids and labels properly generated during preprocessing to ensure compatibility with the ConcatDataset logic.

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

1 participant