ROCm / ROCm/AMDMIGraphX

[Issue]: Model compilation fails with more than one dynamic dimension specified

Open
#4,844 0 comments 0 reactions 1 assignee View on GitHub

@shivadbhavsar is already working on this.

Since May 6, 2026.

Dominant language
C++
Stars
333
Forks
150
Avg merge
4d 19h
Merged PRs (30d)
54

Description

Problem description

MIGraphX fails to compile even simple models when more than one dynamic dimension is specified.

The compilation usually fails with this error message:

RuntimeError: src/shape.cpp:391: lens: SHAPE: lens() called on a dynamic shape

Also, the MIGRAPHX_ENABLE_FULL_DYNAMIC environment variable doesn't help whether or not it's set to 1.

Steps to reproduce

import math
import migraphx
import torch

EMBEDDING_COUNT = 32
EMBEDDING_DIM = 16
BATCH_SIZE = 4

torch.inference_mode(True)
torch.cuda.set_device("cuda:0")

model = torch.nn.Embedding(EMBEDDING_COUNT, EMBEDDING_DIM)
model.eval()
input_batch = torch.arange(math.ceil(EMBEDDING_COUNT / 2)).repeat(BATCH_SIZE, 1).contiguous()

torch.onnx.export(
    model,
    (input_batch,),
    "model.onnx",
    external_data=False,
    dynamo=True,
    dynamic_shapes=[
        {0: torch.export.Dim.DYNAMIC, 1: torch.export.Dim.DYNAMIC},
    ],
)

migraphx_model = migraphx.parse_onnx("model.onnx", map_dyn_input_dims={
    "input": [
        migraphx.shape.dynamic_dimension(1, BATCH_SIZE, {BATCH_SIZE}),
        migraphx.shape.dynamic_dimension(1, 64, {1}),
    ],
})
migraphx_model.compile(migraphx.get_target("gpu"), offload_copy=False)

We want to note that we've observed the same issue with larger models, but we've created this reproducer script with a single node for simpler analysis.

Environment

OS: Debian GNU/Linux 12 (bookworm)
CPU: AMD Ryzen 9 9950X
GPU: AMD Radeon AI PRO R9700
ROCm version: 7.2.1
MIGraphX version: 2.16.0.dev+20250912-17-406-gb91f1c0c0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.