Skip to content

DataDependent Path Is Reported In RemoveRedundantRashapePattern1 #431

@dayo09

Description

@dayo09

What?

While exporting multimodal model's RoPE, data dependent path error is reported.

--------------------------------------------------------------------------
GuardOnDataDependentSymNode               Traceback (most recent call last)
Cell In[20], line 5
      2 #name = 'model.visual.blocks.0.attn'
      3 #name = 'model.language_model.layers.0.self_attn'
      4 name = 'visual.rotary_pos_emb'
----> 5 sess.export_submodule_(name)
      7 #record = capture.records[name]
      8 
      9 # [ (name, type(value)) for (name, value) in record.items() ]
     10 # pp(record['kwargs']['past_key_values'])

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/vlmexport/export.py:28, in Session.export_submodule_(self, key)
     25 args = record['args']
     26 kwargs = record['kwargs']
---> 28 tico.convert(module, args=args, kwargs=kwargs).save(self._output_prefix / f'{key}.circle')

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/tico/utils/convert.py:323, in convert(mod, args, kwargs, dynamic_shapes, strict, config)
    318 with torch.no_grad():
    319     exported_program = export(
    320         mod, args, kwargs, dynamic_shapes=dynamic_shapes, strict=strict
    321     )
--> 323 circle_binary = convert_exported_module_to_circle(exported_program, config=config)
    325 return CircleModel(circle_binary)

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/tico/utils/convert.py:270, in convert_exported_module_to_circle(exported_program, config)
    223 # TODO Distinguish legalize and optimize
    224 circle_legalize = PassManager(
    225     passes=[
    226         FillMetaVal(),
   (...)    268     ]
    269 )
--> 270 circle_legalize.run(exported_program)
    272 # After this stage, ExportedProgram invariant is broken, i.e.,
    273 # graph can have a constant torch.tensor not lifted to a placeholder
    274 circle_legalize = PassManager(
    275     passes=[
    276         FillMetaVal(),
    277         CastMixedTypeArgs(preserve_ep_invariant=False),
    278     ]
    279 )

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/tico/utils/passes.py:65, in PassManager.run(self, exported_program)
     59 for _pass in self.passes:
     60     # Automatically update the signatures of the input and output.
     61     # https://github.com/pytorch/executorch/issues/4013#issuecomment-2187161844
     62     with exported_program.graph_module._set_replace_hook(
     63         exported_program.graph_signature.get_replace_hook()
     64     ):
---> 65         result = _pass.call(exported_program)
     66     modified = modified or result.modified
     67     if modified and self.strategy == PassStrategy.RESTART:

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/tico/utils/trace_decorators.py:63, in trace_graph_diff_on_pass.<locals>._call_traced.<locals>.wrapped(*args)
     61 assert isinstance(graph_module, torch.fx.GraphModule), type(graph_module)
     62 capture(graph_module.graph)
---> 63 ret = fn(*args)
     64 log(graph_module.graph, title=str(cls.__name__), recapture=False)
     65 return ret

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/tico/passes/remove_redundant_reshape.py:81, in RemoveRedundantReshapePattern1.call(self, exported_program)
     79 reshape1_input = reshape1_args.input
     80 # `(AxBxC) - aten.reshape` - (1xAxBxC)
---> 81 if [1] + list(extract_shape(reshape1_input)) != list(
     82     extract_shape(reshape1)
     83 ):
     84     continue
     86 ### permute

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/__init__.py:751, in SymBool.__bool__(self)
    750 def __bool__(self):
--> 751     return self.node.bool_()

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py:616, in SymNode.bool_(self)
    615 def bool_(self):
--> 616     return self.guard_bool("", 0)

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py:538, in SymNode.guard_bool(self, file, line)
    535 def guard_bool(self, file, line):
    536     # TODO: use the file/line for some useful diagnostic on why a
    537     # guard occurred
--> 538     r = self.evaluate()
    539     try:
    540         return bool(r)

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py:512, in SymNode.evaluate(self, size_oblivious)
    511 def evaluate(self, size_oblivious=False):
--> 512     return self.shape_env.evaluate_sym_node(self, size_oblivious)

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py:7223, in ShapeEnv.evaluate_sym_node(self, sym_node, size_oblivious, fallback_value)
   7218 """
   7219 Given a a SymNode, evaluates sym_node.expr, adding guards if necessary.
   7220 """
   7222 self._expr_sym_node_id = id(sym_node)
-> 7223 return self.evaluate_expr(
   7224     sym_node.expr,
   7225     sym_node.hint,
   7226     sym_node.fx_node,
   7227     size_oblivious,
   7228     fallback_value=fallback_value,
   7229 )

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py:7323, in ShapeEnv.evaluate_expr(self, orig_expr, hint, fx_node, size_oblivious, fallback_value, forcing_spec)
   7321 # Add extra state that evaluate_expr() depends on.
   7322 suppress_guards_tls = ShapeEnv._suppress_guards_tls()
-> 7323 return self._inner_evaluate_expr(
   7324     orig_expr,
   7325     hint,
   7326     fx_node,
   7327     size_oblivious,
   7328     forcing_spec,
   7329     suppress_guards_tls,
   7330     fallback_value,
   7331 )

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/recording.py:272, in record_shapeenv_event.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    265 try:
    266     if not shape_env.should_record_events or shape_env.is_recording:  # type: ignore[has-type]
    267         # If ShapeEnv is already recording an event, call the wrapped
    268         # function directly.
    269         #
    270         # NB: here, we skip the check of whether all ShapeEnv instances
    271         # are equal, in favor of a faster dispatch.
--> 272         return retlog(fn(*args, **kwargs))
    274     # Retrieve an instance of ShapeEnv.
    275     # Assumption: the collection of args and kwargs may not reference
    276     # different ShapeEnv instances.
    277     self = _extract_shape_env_and_assert_equal(args, kwargs)

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py:7346, in ShapeEnv._inner_evaluate_expr(self, orig_expr, hint, fx_node, size_oblivious, forcing_spec, _suppress_guards_tls, fallback_value)
   7333 @lru_cache(256)
   7334 @record_shapeenv_event(save_tracked_fakes=True, name="evaluate_expr")
   7335 def _inner_evaluate_expr(
   (...)   7343     fallback_value: Optional[bool] = None,
   7344 ) -> sympy.Basic:
   7345     try:
-> 7346         return self._evaluate_expr(
   7347             orig_expr,
   7348             hint,
   7349             fx_node,
   7350             size_oblivious,
   7351             fallback_value,
   7352             forcing_spec=forcing_spec,
   7353         )
   7354     except Exception as e:
   7355         if isinstance(e, GuardOnDataDependentSymNode):

File ~/opt/miniforge3/envs/Qwen2.5-VL/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py:7570, in ShapeEnv._evaluate_expr(self, orig_expr, hint, fx_node, size_oblivious, fallback_value, forcing_spec)
   7566         if not size_oblivious:
   7567             size_oblivious_result = self._maybe_evaluate_static(
   7568                 expr, size_oblivious=True
   7569             )
-> 7570         raise self._make_data_dependent_error(
   7571             expr.xreplace(self.var_to_val),
   7572             expr,
   7573             size_oblivious_result=size_oblivious_result,
   7574             expr_sym_node_id=self._expr_sym_node_id,
   7575         )
   7576 else:
   7577     expr = new_expr

versions

  • torch: '2.8.0+cu128'
  • torchvision: '0.23.0+cu128'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions