pytorch / torchchat

Run PyTorch LLMs locally on servers, desktop and mobile
BSD 3-Clause "New" or "Revised" License
3.4k stars 225 forks source link

Torchchat generate cannot work with device=fast #1373

Closed jenniew closed 2 weeks ago

jenniew commented 2 weeks ago

πŸ› Describe the bug

Torchchat generate and server cannot work with device=fast.

The example command: python3 torchchat.py generate llama3.1 --prompt "write me a story about a boy and his bear" --device fast

And the error is as below:

Using device=fast
Loading model...
Time to load model: 0.04 seconds
Traceback (most recent call last):
  File "/home/sdp/jwang/torchchat/torchchat.py", line 91, in <module>
    server_main(args)
  File "/home/sdp/jwang/torchchat/torchchat/usages/server.py", line 127, in main
    app = create_app(args)
  File "/home/sdp/jwang/torchchat/torchchat/usages/server.py", line 38, in create_app
    gen: OpenAiApiGenerator = initialize_generator(args)
  File "/home/sdp/jwang/torchchat/torchchat/usages/server.py", line 115, in initialize_generator
    return OpenAiApiGenerator(
  File "/home/sdp/jwang/torchchat/torchchat/usages/openai_api.py", line 283, in __init__
    super().__init__(*args, **kwargs)
  File "/home/sdp/jwang/torchchat/torchchat/generate.py", line 293, in __init__
    self.model = _initialize_model(self.builder_args, self.quantize, self.tokenizer)
  File "/home/sdp/jwang/torchchat/torchchat/cli/builder.py", line 603, in _initialize_model
    model = _load_model(builder_args)
  File "/home/sdp/jwang/torchchat/torchchat/cli/builder.py", line 465, in _load_model
    model = _load_model_default(builder_args)
  File "/home/sdp/jwang/torchchat/torchchat/cli/builder.py", line 427, in _load_model_default
    checkpoint = _load_checkpoint(builder_args)
  File "/home/sdp/jwang/torchchat/torchchat/cli/builder.py", line 412, in _load_checkpoint
    checkpoint = torch.load(
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 1359, in load
    return _load(
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 1856, in _load
    result = unpickler.load()
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/_weights_only_unpickler.py", line 385, in load
    self.append(self.persistent_load(pid))
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 1820, in persistent_load
    typed_storage = load_tensor(
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 1792, in load_tensor
    wrap_storage=restore_location(storage, location),
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 1693, in restore_location
    return default_restore_location(storage, map_location)
  File "/home/sdp/miniforge3/envs/jiao-pt/lib/python3.10/site-packages/torch/serialization.py", line 604, in default_restore_location
    raise RuntimeError(
RuntimeError: don't know how to restore data location of torch.storage.UntypedStorage (tagged with fast)

Versions

Collecting environment information... PyTorch version: 2.6.0.dev20241002+cpu Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

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

Python version: 3.10.15 | packaged by conda-forge | (main, Oct 16 2024, 01:24:24) [GCC 13.3.0] (64-bit runtime) Python platform: Linux-5.15.0-124-generic-x86_64-with-glibc2.35 Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA 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, 48 bits virtual Byte Order: Little Endian CPU(s): 256 On-line CPU(s) list: 0-255 Vendor ID: GenuineIntel Model name: GENUINE INTEL(R) XEON(R) CPU family: 6 Model: 175 Thread(s) per core: 1 Core(s) per socket: 128 Socket(s): 2 Stepping: 0 CPU max MHz: 2900.0000 CPU min MHz: 800.0000 BogoMIPS: 3200.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 cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize pconfig arch_lbr flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 8 MiB (256 instances) L1i cache: 16 MiB (256 instances) L2 cache: 256 MiB (64 instances) L3 cache: 192 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-127 NUMA node1 CPU(s): 128-255 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: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS Not affected; BHI BHI_DIS_S Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] numpy==1.26.4 [pip3] torch==2.6.0.dev20241002+cpu [pip3] torchao==0.5.0 [pip3] torchtune==0.4.0.dev20241010+cpu [pip3] torchvision==0.20.0.dev20241002+cpu [conda] numpy 1.26.4 pypi_0 pypi [conda] torch 2.6.0.dev20241002+cpu pypi_0 pypi [conda] torchao 0.5.0 pypi_0 pypi [conda] torchtune 0.4.0.dev20241010+cpu pypi_0 pypi [conda] torchvision 0.20.0.dev20241002+cpu pypi_0 pypi

Jack-Khuu commented 2 weeks ago

Looks like a bug from https://github.com/pytorch/torchchat/commit/93f713f12507b5cef18a42c411030c90b9326369

Looking into it

Jack-Khuu commented 2 weeks ago

Fixed in https://github.com/pytorch/torchchat/pull/1374