Guest User

Untitled

a guest
Oct 6th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. import torch
  2. from diffusers import ModularPipeline, ComponentsManager
  3.  
  4. repo_id = "black-forest-labs/FLUX.1-dev"
  5. device = "cuda"
  6.  
  7. components = ComponentsManager()
  8. components.enable_auto_cpu_offload(device=device)
  9.  
  10. text_blocks = ModularPipeline.from_pretrained(repo_id, components_manager=components).blocks.sub_blocks.pop("text_encoder")
  11. text_encoder_node = text_blocks.init_pipeline(repo_id, components_manager=components)
  12. text_encoder_node.load_components(torch_dtype=torch.bfloat16)
  13.  
  14. prompt = "a dog sitting by the see waiting for its companion to come"
  15.  
  16. # We should provide text embedding related inputs (`max_sequence_length`, for example)
  17. # to the following step as it's utilized during the text embedding preparation
  18. # step and NOT in the denoising step.
  19. text_state = text_encoder_node(prompt=prompt, max_sequence_length=512)
  20. text_embeddings = text_state.get_by_kwargs("denoiser_input_fields")
  21.  
  22. denoise_blocks = ModularPipeline.from_pretrained(repo_id).blocks.sub_blocks.pop("denoise")
  23. denoise_node = denoise_blocks.init_pipeline(repo_id, components_manager=components)
  24. denoise_node.load_components(torch_dtype=torch.bfloat16)
  25.  
  26. print(f"{text_embeddings.keys()=}")
  27.  
  28. denoise_state = denoise_node(
  29. **text_embeddings,
  30. guidance_scale=4.5,
  31. num_inference_steps=28,
  32. generator=torch.Generator(device=device).manual_seed(0),
  33. )
  34.  
  35.  
  36. Traceback (most recent call last):
  37. File "/fsx/sayak/diffusers/check_flux_sage.py", line 13, in <module>
  38. image = pipe(
  39. File "/fsx/sayak/miniconda3/envs/diffusers/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
  40. return func(*args, **kwargs)
  41. File "/fsx/sayak/diffusers/src/diffusers/pipelines/flux/pipeline_flux.py", line 944, in __call__
  42. noise_pred = self.transformer(
  43. File "/fsx/sayak/miniconda3/envs/diffusers/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
  44. return self._call_impl(*args, **kwargs)
  45. File "/fsx/sayak/miniconda3/envs/diffusers/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
  46. return forward_call(*args, **kwargs)
  47. File "/fsx/sayak/diffusers/src/diffusers/models/transformers/transformer_flux.py", line 739, in forward
  48. encoder_hidden_states, hidden_states = block(
  49. File "/fsx/sayak/miniconda3/envs/diffusers/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1771, in _wrapped_call_impl
  50. return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
  51. File "/fsx/sayak/miniconda3/envs/diffusers/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 745, in compile_wrapper
  52. raise e.with_traceback(None) from e.__cause__ # User compiler error
  53. torch._dynamo.exc.Unsupported: torch.* op returned non-Tensor
  54. Explanation: torch.* ops that return a non-Tensor cannot be traced into the Dynamo FX graph output
  55.  
  56.  
  57. Developer debug context: example_value type: int; op: call_function; target: <function device_count at 0x7f249f6477f0>
  58.  
  59.  
  60. from user code:
  61. File "/fsx/sayak/diffusers/src/diffusers/models/transformers/transformer_flux.py", line 453, in forward
  62. attention_outputs = self.attn(
  63. File "/fsx/sayak/diffusers/src/diffusers/models/transformers/transformer_flux.py", line 352, in forward
  64. return self.processor(self, hidden_states, encoder_hidden_states, attention_mask, image_rotary_emb, **kwargs)
  65. File "/fsx/sayak/diffusers/src/diffusers/models/transformers/transformer_flux.py", line 118, in __call__
  66. hidden_states = dispatch_attention_fn(
  67. File "/fsx/sayak/diffusers/src/diffusers/models/attention_dispatch.py", line 331, in dispatch_attention_fn
  68. return backend_fn(**kwargs)
  69. File "/fsx/sayak/diffusers/src/diffusers/models/attention_dispatch.py", line 1780, in _sage_attention_hub
  70. out = sage_attn_func_hub(
  71. File "/fsx/sayak/.cache/models--kernels-community--sage_attention/snapshots/c08f35540cbb059f0f245eb65e2aa072df3549ad/build/torch28-cxx11-cu129-x86_64-linux/sage_attention/core.py", line 120, in sageattn
  72. arch = get_cuda_arch_versions()[q.device.index]
  73. File "/fsx/sayak/.cache/models--kernels-community--sage_attention/snapshots/c08f35540cbb059f0f245eb65e2aa072df3549ad/build/torch28-cxx11-cu129-x86_64-linux/sage_attention/core.py", line 50, in get_cuda_arch_versions
  74. for i in range(torch.cuda.device_count()):
  75.  
  76. Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
Advertisement
Add Comment
Please, Sign In to add comment