OneTrainer icon indicating copy to clipboard operation
OneTrainer copied to clipboard

[Bug]: Enabling both compile and LoRA dropout crashes

Open NerissG opened this issue 11 months ago • 6 comments

What happened?

When enabling both the Compile transformer blocks in the model tab option and the Dropout Probability in the LoRA tab. The training crashes after the first step (which makes a lot of sense).

What did you expect would happen?

Either:

  • the dropout should automatically be turned off when compile is turned on with a warning in the console
  • a clear error message should be provided
  • the training cannot be started when both are enabled

Relevant log output


Generate and upload debug_report.log

No response

NerissG avatar Dec 15 '25 13:12 NerissG

what do you mean by "silently"? do you not get an error message? I can reproduce the issue, but get the error log below. This appears to be this bug at pytorch: https://github.com/pytorch/pytorch/issues/164186

  File ".../OneTrainer/venv/src/diffusers/src/diffusers/models/transformers/transformer_z_image.py", line 644, in forward
    unified = layer(unified, unified_attn_mask, unified_freqs_cis, adaln_input)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1771, in _wrapped_call_impl
    return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 749, in compile_wrapper
    raise e.remove_dynamo_frames() from None  # see TORCHDYNAMO_VERBOSE=1
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/eval_frame.py", line 736, in compile_wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 1495, in __call__
    return self._torchdynamo_orig_callable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 629, in __call__
    return _compile(
           ^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 1111, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_utils_internal.py", line 97, in wrapper_function
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 793, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 832, in _compile_inner
    out_code = transform_code_object(code, transform)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/bytecode_transformation.py", line 1424, in transform_code_object
    transformations(instructions, code_options)
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 267, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/convert_frame.py", line 753, in transform
    tracer.run()
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/symbolic_convert.py", line 3497, in run
    super().run()
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/symbolic_convert.py", line 1363, in run
    while self.step():
          ^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/symbolic_convert.py", line 1267, in step
    self.dispatch_table[inst.opcode](self, inst)
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/symbolic_convert.py", line 3672, in RETURN_VALUE
    self._return(inst)
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/symbolic_convert.py", line 3653, in _return
    all_stack_locals_metadata = self.output.compile_subgraph(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 1382, in compile_subgraph
    self.compile_and_call_fx_graph(
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 1696, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm, self.example_inputs())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 1811, in call_user_compiler
    return self._call_user_compiler(gm, example_inputs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 1871, in _call_user_compiler
    raise BackendCompilerFailed(
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/output_graph.py", line 1846, in _call_user_compiler
    compiled_fn = compiler_fn(gm, example_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/repro/after_dynamo.py", line 150, in __call__
    compiled_gm = compiler_fn(gm, example_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/__init__.py", line 2380, in __call__
    return compile_fx(model_, inputs_, config_patches=self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_inductor/compile_fx.py", line 2418, in compile_fx
    return aot_autograd(
           ^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_dynamo/backends/common.py", line 109, in __call__
    cg = aot_module_simplified(gm, example_inputs, **self.kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.py", line 1199, in aot_module_simplified
    compiled_fn = AOTAutogradCache.load(
                  ^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/autograd_cache.py", line 1140, in load
    compiled_fn = dispatch_and_compile()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.py", line 1184, in dispatch_and_compile
    compiled_fn, _ = create_aot_dispatcher_function(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.py", line 576, in create_aot_dispatcher_function
    return _create_aot_dispatcher_function(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/aot_autograd.py", line 836, in _create_aot_dispatcher_function
    compiled_fn, fw_metadata = compiler_fn(
                               ^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 1320, in aot_dispatch_autograd
    fw_module, bw_module = aot_config.partition_fn(
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_inductor/compile_fx.py", line 2300, in partition_fn
    return min_cut_rematerialization_partition(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/partitioners.py", line 2640, in min_cut_rematerialization_partition
    fw_module, bw_module = _extract_fwd_bwd_modules(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/partitioners.py", line 817, in _extract_fwd_bwd_modules
    bwd_graph = _extract_graph_with_inputs_outputs(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../OneTrainer/venv/lib/python3.12/site-packages/torch/_functorch/partitioners.py", line 232, in _extract_graph_with_inputs_outputs
    assert not isinstance(
           ^^^^^^^^^^^^^^^
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
AssertionError: Node convert_element_type_209 was invalid, but is output

dxqb avatar Dec 15 '25 20:12 dxqb

unless this is serious enough for anyone that it warrants looking for a workaround, I'd wait until torch have fixed it.

https://github.com/pytorch/pytorch/issues/164186

dxqb avatar Dec 21 '25 05:12 dxqb

Sorry I forgot to reply. It indeed does not crash silently. I thought dropout and compile were incompatible, what I wrote mostly doesn't apply. Adding error handling for a pytorch bug doesn't sound like the greatest priority.

NerissG avatar Dec 21 '25 09:12 NerissG

according to https://github.com/pytorch/pytorch/issues/164186 this is fixed in pytorch, but probably not in a release yet

dxqb avatar Jan 29 '26 12:01 dxqb

The fix landed in PyTorch 2.11.0 (released 2026-03-23). It is not in 2.10.

dxqb avatar May 15 '26 13:05 dxqb

The crash occurs when both Compile transformer blocks and Dropout Probability are enabled, indicating a conflict in the training setup. I would inspect the logic in LoRAModule.py to ensure proper handling of these options. A potential fix could involve disabling the dropout option automatically when compilation is enabled, along with a warning in the console. What kind of error handling or messaging should we implement to guide users in this scenario?

Stop using a bot and posting bot comments.

O-J1 avatar Jun 29 '26 11:06 O-J1