Skip to content

[torch Issue]: system freeze with torch.compile on gfx1151 #1937

Closed

Description

@alanzjl

Problem Description

Running torch.compile freezes the entire system without much output. Minimum code to reproduce:

import torch
import torch.nn as nn

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(1024, 512)
        self.relu = nn.ReLU()
        self.fc2 = nn.Linear(512, 256)
        self.fc3 = nn.Linear(256, 10)

    def forward(self, x):
        x = self.relu(self.fc1(x))
        x = self.relu(self.fc2(x))
        return self.fc3(x)

model = SimpleModel().to("cuda")
compiled_model = torch.compile(model)
x = torch.randn(32, 1024, device="cuda")
output = compiled_model(x)

Fresh Ubuntu 24.04.3 on Strix Halo (Bosgame M5, 128G). Installed the rock with

python -m pip install \
  --index-url https://rocm.nightlies.amd.com/v2/gfx1151/ \
  "rocm[libraries,devel]"
python -m pip install \
  --index-url https://rocm.nightlies.amd.com/v2/gfx1151/ \
  --pre torch torchaudio torchvision

Ran into the same issue when using the official torch installation this.

It also seems like the issue might be related to garbage collecting & cleaning, because I do not have trouble running anything with the compiled model, but as soon as the script (that has a torch.compile in it) quits, the whole system then freezes.

Operating System

Ubuntu 24.04.3

CPU

AMD RYZEN AI MAX+ 395 w/ Radeon 8060S

GPU

Radeon 8060S / gfx1151

ROCm Version

7.1.0

ROCm Component

No response

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

Activity

  1. Epliz commented on Oct 29, 2025

    @Epliz

    I can confirm, same issue (gfx1151 too) with even a simpler code:

    import torch
    import torch.nn as nn
    
    class SimpleModel(nn.Module):
        def __init__(self):
            super().__init__()
    
        def forward(self, x):
            return x
    
    model = SimpleModel().to("cuda")
    compiled_model = torch.compile(model)
  2. taylding-amd commented on Oct 29, 2025

    @taylding-amd

    Hi @alanzjl, is this issue the same as the one you submitted earlier? Also, can you verify whether the issue has been resolved in PyTorch 2.10?

  3. taylding-amd commented on Oct 29, 2025

    @taylding-amd

    Hi @Epliz, I tried your code on my machine and was not able to reproduce the issue, could you please try again with PyTorch 2.10?

  4. moved this from TODO to In Progress in TheRock Triageon Oct 29, 2025
  5. Epliz commented on Oct 29, 2025

    @Epliz

    Hi @taylding-amd ,

    To check, I installed torch 2.10 and rocm 7.10 from the v2 nightlies with:

    python -m pip install --index-url https://rocm.nightlies.amd.com/v2/gfx1151/ -U torch==2.10.0a0+rocm7.10.0a20251015 torchvision

    The reduced version of the program I shared above did not trigger a hang with torch 2.10.
    However the original program from the original post still did.

    If I install from v2-staging

    python -m pip install --index-url https://rocm.nightlies.amd.com/v2-staging/gfx1151/ -U torch==2.10.0a0+rocm7.10.0a20251029

    Then the reduced version exits correctly, and the first version sometimes hangs, sometimes segfaults.

    Here is the end of the logs I could capture with AMD_LOG_LEVEL=7. I guess they stop when it actually hangs, but the fact that you can see "exit" at the end indicates that it reached the print statement I put at the end of the python script, and that it was exiting.
    I am not sure what logs would be useful. I guess it is a hang when trying to synchronize the CPU and GPU.

    logs_end.txt

    (The full logs at 40MB and could not download)

    Best,
    Epliz

  6. taylding-amd commented on Oct 30, 2025

    @taylding-amd

    Thanks, @Epliz, for checking. I wasn’t able to reproduce the hang on my machine. Which OS are you using?

  7. Epliz commented on Oct 31, 2025

    @Epliz

    Hi @taylding-amd ,

    I am on Ubuntu 24.04.3 LTS, kernel 6.14.0-34-generic, ROCM 7.0.2 "host" installed from the installation packages, ROCM 7.10 through pip.

  8. Epliz commented on Oct 31, 2025

    @Epliz

    So, I saw there are other issues being reported (e.g. https://github.com/ROCm/legacy-rocm-build/issues/5590 ), so I updated my firmware with linux-firmware.git .

    While that did not solve fully the hang of the application, it made the hang to not be a total system hang and I could get some interesting dmesg output that seems to give an idea of where the cpu gets blocked:

    [  196.456906] watchdog: BUG: soft lockup - CPU#31 stuck for 26s! [python3:4415]
    [  196.456908] Modules linked in: ccm rfcomm snd_seq_dummy snd_hrtimer hid_sensor_gyro_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf hid_sensor_iio_common industrialio hid_sensor_hub cmac algif_hash algif_skcipher af_alg qrtr bnep ip6t_REJECT nf_reject_ipv6 xt_hl ip6t_rt ipt_REJECT nf_reject_ipv4 xt_LOG nf_log_syslog nft_limit xt_limit xt_addrtype xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nf_tables binfmt_misc exfat nls_iso8859_1 snd_hda_scodec_cs35l56_spi snd_acp_legacy_mach snd_acp_mach snd_soc_nau8821 amd_atl intel_rapl_msr snd_acp3x_rn intel_rapl_common snd_acp70 snd_acp_i2s snd_acp_pdm snd_soc_dmic snd_acp_pcm snd_sof_amd_acp70 snd_sof_amd_acp63 snd_ctl_led snd_sof_amd_vangogh snd_sof_amd_rembrandt snd_hda_codec_realtek snd_sof_amd_renoir snd_sof_amd_acp snd_hda_codec_generic snd_sof_pci snd_hda_scodec_component snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_hda_codec_hdmi snd_pci_ps snd_soc_acpi_amd_match snd_amd_sdw_acpi edac_mce_amd soundwire_amd
    [  196.456923]  mt7925e soundwire_generic_allocation soundwire_bus snd_hda_intel mt7925_common snd_intel_dspcfg snd_soc_sdca mt792x_lib snd_intel_sdw_acpi snd_hda_scodec_cs35l56_i2c snd_soc_core kvm_amd snd_hda_scodec_cs35l56 mt76_connac_lib snd_hda_codec snd_hda_cirrus_scodec snd_soc_cs35l56_shared snd_compress mt76 snd_hda_core ac97_bus snd_soc_cs_amp_lib kvm snd_pcm_dmaengine cs_dsp snd_hwdep snd_rpl_pci_acp6x snd_seq_midi irqbypass snd_seq_midi_event mac80211 polyval_clmulni snd_acp_pci polyval_generic snd_rawmidi ghash_clmulni_intel snd_acp_legacy_common btusb sha256_ssse3 snd_pci_acp6x btrtl sha1_ssse3 aesni_intel snd_seq btintel snd_pcm btbcm crypto_simd hp_wmi btmtk snd_seq_device cryptd spd5118 bluetooth snd_pci_acp5x sparse_keymap wmi_bmof rapl amd_pmf snd_timer snd_rn_pci_acp3x cfg80211 snd_acp_config amdtee amdxdna snd snd_soc_acpi i2c_piix4 gpu_sched libarc4 snd_pci_acp3x soundcore i2c_smbus ccp tee platform_profile wireless_hotkey serial_multi_instantiate amd_pmc input_leds joydev mac_hid serio_raw
    [  196.456936]  sch_fq_codel msr parport_pc ppdev lp parport efi_pstore nfnetlink dmi_sysfs ip_tables x_tables autofs4 amdgpu(OE) amddrm_ttm_helper(OE) amdttm(OE) amddrm_buddy(OE) amdxcp(OE) amddrm_exec(OE) amd_sched(OE) amdkcl(OE) drm_panel_backlight_quirks drm_display_helper cec rc_core nvme nvme_core i2c_algo_bit video hid_multitouch ucsi_acpi drm_ttm_helper hid_generic typec_ucsi thunderbolt ttm amd_sfh nvme_auth typec wmi i2c_hid_acpi i2c_hid hid
    [  196.456944] CPU: 31 UID: 1000 PID: 4415 Comm: python3 Tainted: G           OEL     6.14.0-34-generic #34~24.04.1-Ubuntu
    [  196.456946] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE, [L]=SOFTLOCKUP
    [  196.456946] Hardware name: HP HP ZBook Ultra G1a 14 inch Mobile Workstation PC/8D01, BIOS X89 Ver. 01.03.00 04/25/2025
    [  196.456947] RIP: 0010:native_queued_spin_lock_slowpath+0x2be/0x310
    [  196.456949] Code: 4d 63 ff 4c 8d a8 c0 80 03 00 49 81 ff 00 20 00 00 73 49 4e 03 2c fd 40 af f6 ba 4d 89 65 00 41 8b 44 24 08 85 c0 75 0b f3 90 <41> 8b 44 24 08 85 c0 74 f5 49 8b 14 24 48 85 d2 0f 84 64 ff ff ff
    [  196.456949] RSP: 0018:ffffca07057678e0 EFLAGS: 00000246
    [  196.456950] RAX: 0000000000000000 RBX: ffff88e901f3dbac RCX: 0000000000000000
    [  196.456951] RDX: 0000000000000017 RSI: 00000000005c0101 RDI: ffff88e901f3dbac
    [  196.456951] RBP: ffffca0705767908 R08: 0000000000000000 R09: 0000000000000000
    [  196.456952] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88f05e1b80c0
    [  196.456952] R13: ffff88f05dd380c0 R14: 0000000000800000 R15: 0000000000000016
    [  196.456953] FS:  0000000000000000(0000) GS:ffff88f05e180000(0000) knlGS:0000000000000000
    [  196.456954] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  196.456954] CR2: 000000003b1324e0 CR3: 00000001acc40000 CR4: 0000000000f50ef0
    [  196.456955] PKRU: 55555554
    [  196.456955] Call Trace:
    [  196.456955]  <TASK>
    [  196.456956]  _raw_spin_lock+0x3f/0x60
    [  196.456957]  mmu_interval_notifier_remove+0x45/0x1d0
    [  196.456958]  ? __vm_area_free+0x56/0x80
    [  196.456960]  ? kmem_cache_free+0x3c4/0x470
    [  196.456961]  amdxdna_gem_vm_close+0x3a/0x70 [amdxdna]
    [  196.456965]  remove_vma+0x2e/0x90
    [  196.456966]  exit_mmap+0x1e3/0x3f0
    [  196.456969]  mmput+0x69/0x130
    [  196.456969]  exit_mm+0xb8/0x120
    [  196.456971]  do_exit+0x234/0x4e0
    [  196.456972]  do_group_exit+0x34/0x90
    [  196.456973]  get_signal+0x8cb/0x8d0
    [  196.456974]  ? hrtimer_nanosleep+0x8c/0x110
    [  196.456975]  arch_do_signal_or_restart+0x39/0x110
    [  196.456977]  syscall_exit_to_user_mode+0x146/0x1d0
    [  196.456978]  do_syscall_64+0x8a/0x170
    [  196.456979]  ? arch_exit_to_user_mode_prepare.isra.0+0x22/0xd0
    [  196.456980]  ? syscall_exit_to_user_mode+0x38/0x1d0
    [  196.456981]  ? do_syscall_64+0x8a/0x170
    [  196.456982]  ? handle_pte_fault+0x1ee/0x200
    [  196.456984]  ? __handle_mm_fault+0x62c/0x770
    [  196.456986]  ? __count_memcg_events+0xd3/0x1a0
    [  196.456986]  ? count_memcg_events.constprop.0+0x2a/0x50
    [  196.456988]  ? handle_mm_fault+0x1df/0x2d0
    [  196.456990]  ? do_user_addr_fault+0x5d5/0x870
    [  196.456991]  ? arch_exit_to_user_mode_prepare.isra.0+0x22/0xd0
    [  196.456991]  ? irqentry_exit_to_user_mode+0x2d/0x1d0
    [  196.456993]  ? irqentry_exit+0x43/0x50
    [  196.456994]  ? exc_page_fault+0x96/0x1e0
    [  196.456995]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
    [  196.456996] RIP: 0033:0x72f379eecadf
    [  196.456997] Code: Unable to access opcode bytes at 0x72f379eecab5.
    [  196.456997] RSP: 002b:000072f1a0bfebb0 EFLAGS: 00000293 ORIG_RAX: 00000000000000e6
    [  196.456998] RAX: fffffffffffffdfe RBX: 000000359dc6dbf8 RCX: 000072f379eecadf
    [  196.456998] RDX: 000072f1a0bfec40 RSI: 0000000000000001 RDI: 0000000000000001
    [  196.456998] RBP: 000072f1a0bfec20 R08: 0000000000000000 R09: 0000000000b495f8
    [  196.456999] R10: 0000000000000000 R11: 0000000000000293 R12: 000072f1a0bfec40
    [  196.456999] R13: 0000000000000001 R14: 000000000064cc00 R15: 0000000000000000
    [  196.457000]  </TASK>
    

    Full dmesg output:

    dmesg.txt

  9. Epliz commented on Oct 31, 2025

    @Epliz

    I will try to install a newer kernel over the weekend to see if it solves the issue

  10. taylding-amd commented on Oct 31, 2025

    @taylding-amd

    You can also try the PyTorch docker images: https://hub.docker.com/r/rocm/pytorch

  11. Epliz commented on Nov 1, 2025

    @Epliz

    Updating the kernel to 6.17 + using amdgpu-dkms from ROCM 7.1 + using the latest firmware from linux-firmware.git solves the hang for me at least.

  12. taylding-amd commented on Nov 5, 2025

    @taylding-amd

    Hi, this issue will be closed now as it's solved in the newest release. Please feel free to reopen it or ask follow-up questions should further assistance be required. Thanks!

  13. moved this from In Progress to Done in TheRock Triageon Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: triageIndicates an issue has been assigned for investigation.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions