Skip to content

RuntimeError in Graph Mode with Tuple Inputs in forward Method #10682

@LiSsHhUuAaIi

Description

@LiSsHhUuAaIi

Summary

I encountered a RuntimeError when running a model in OneFlow's Graph mode that works perfectly in eager mode. The error occurs specifically when the forward method takes a Tuple[int] as input and attempts to create a tensor from it using flow.tensor(ids).

RuntimeError: This is a oneflow bug, please submit an issue...

Code to reproduce bug

import oneflow as flow
import oneflow.nn as nn
from typing import Tuple

class TestModel(nn.Module):
    def __init__(self):
        super(TestModel, self).__init__()

    def forward(self, ids: Tuple[int]) -> int:
        return flow.sum(flow.tensor(ids))

# Test data
ids = flow.tensor([1, 2, 3, 4, 5])

model = TestModel()

# Eager mode works
print("Eager mode result:", model(ids))

# Graph mode fails
class TestGraph(nn.Graph):
    def __init__(self, model):
        super().__init__()
        self.model = model
        
    def build(self, *args):
        return self.model(*args)

g = TestGraph(model)
print("Graph mode result:", g(ids))

System Information

  • OS: Ubuntu 20.04.6 LTS
  • OneFlow version: '1.0.0.dev20251101+cpu'
  • Python version: Python 3.10.19

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions