nod-ai / SHARK-Studio

SHARK Studio -- Web UI for SHARK+IREE High Performance Machine Learning Distribution
Apache License 2.0
1.42k stars 171 forks source link

Hires fix does not work. #1800

Open Arcadia245 opened 1 year ago

Arcadia245 commented 1 year ago

I tried using the hires fix, but it does not work. Here is the error that I get:

Traceback (most recent call last): File "gradio\routes.py", line 488, in run_predict File "gradio\blocks.py", line 1431, in process_api File "gradio\blocks.py", line 1117, in call_function File "gradio\utils.py", line 350, in async_iteration File "gradio\utils.py", line 343, in anext File "anyio\to_thread.py", line 33, in run_sync File "anyio_backends_asyncio.py", line 2101, in run_sync_in_worker_thread File "anyio_backends_asyncio.py", line 828, in run File "gradio\utils.py", line 326, in run_sync_iterator_async File "gradio\utils.py", line 695, in gen_wrapper File "ui\txt2img_ui.py", line 195, in txt2img_inf File "apps\stable_diffusion\src\pipelines\pipeline_shark_stable_diffusion_txt2img.py", line 134, in generate_images File "apps\stable_diffusion\src\pipelines\pipeline_shark_stable_diffusion_utils.py", line 235, in produce_img_latents File "apps\stable_diffusion\src\pipelines\pipeline_shark_stable_diffusion_utils.py", line 114, in load_unet File "apps\stable_diffusion\src\models\model_wrappers.py", line 855, in unet File "apps\stable_diffusion\src\models\model_wrappers.py", line 818, in unet File "apps\stable_diffusion\src\models\model_wrappers.py", line 778, in compile_unet_variants File "apps\stable_diffusion\src\models\model_wrappers.py", line 619, in get_unet File "apps\stable_diffusion\src\utils\utils.py", line 178, in compile_through_fx File "apps\stable_diffusion\src\utils\utils.py", line 80, in _compile_module File "shark\shark_inference.py", line 198, in save_module return export_iree_module_to_vmfb( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "shark\iree_utils\compile_utils.py", line 491, in export_iree_module_to_vmfb flatbuffer_blob = compile_module_to_flatbuffer( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "shark\iree_utils\compile_utils.py", line 317, in compile_module_to_flatbuffer flatbuffer_blob = ireec.compile_str( ^^^^^^^^^^^^^^^^^^ File "iree\compiler\tools\core.py", line 300, in compile_str File "iree\compiler\tools\binaries.py", line 199, in invoke_immediate SystemExit: Error invoking IREE compiler tool iree-compile.exe Diagnostics:

.13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:39:15: error: failed to legalize operation 'arith.constant' .13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:39:15: error: failed to run translation of source executable to target executable for backend #hal.executable.target<"vulkan", "vulkan-spirv-fb", {spirv.target_env = #spirv.target_env<#spirv.vce, api=Vulkan, AMD:DiscreteGPU, #spirv.resource_limits>, #spirv.coop_matrix_props>, #spirv.coop_matrix_props>]>>}> .13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:39:15: error: failed to serialize executables .13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:41:15: error: failed to legalize operation 'arith.constant' .13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:41:15: error: failed to run translation of source executable to target executable for backend #hal.executable.target<"vulkan", "vulkan-spirv-fb", {spirv.target_env = #spirv.target_env<#spirv.vce, api=Vulkan, AMD:DiscreteGPU, #spirv.resource_limits>, #spirv.coop_matrix_props>, #spirv.coop_matrix_props>]>>}> .13 from torch\fx\experimental\proxy_tensor.py:477 in wrapped:41:15: error: failed to serialize executables Invoked with: iree-compile.exe C:\Users\xxxx\AppData\Local\Temp\_MEI300922\iree\compiler\tools\..\_mlir_libs\iree-compile.exe - --iree-input-type=tm_tensor --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=vulkan --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-llvmcpu-target-cpu-features=host --iree-vulkan-target-env=#vk.target_env: vector<3xi32>, subgroupSize = 64, subgroupFeatures = 255: i32, minSubgroupSize = 32, maxSubgroupSize = 64, shaderFloat16 = unit, shaderFloat64 = unit, shaderInt8 = unit, shaderInt16 = unit, shaderInt64 = unit, storageBuffer16BitAccess = unit, storagePushConstant16 = unit, uniformAndStorageBuffer16BitAccess = unit, storageBuffer8BitAccess = unit, storagePushConstant8 = unit, uniformAndStorageBuffer8BitAccess = unit, variablePointers = unit, variablePointersStorageBuffer = unit, cooperativeMatrixPropertiesNV = [#vk.coop_matrix_props>], shaderIntegerDotProduct = unit >> --iree-stream-resource-max-allocation-size=4294967295 --iree-vm-bytecode-module-strip-source-map=true --iree-util-zero-fill-elided-attrs --iree-opt-strip-assertions=true --verify=false -iree-vulkan-target-triple=rdna3-7900-windows Need more information? Set IREE_SAVE_TEMPS=/some/dir in your environment to save all artifacts and reproducers.
monorimet commented 1 year ago

This compile error has been fixed upstream in SRT, but I ran into the following runtime error with the euler_scale_model_input submodel:

Traceback (most recent call last):
  File "gradio\queueing.py", line 388, in call_prediction
  File "gradio\route_utils.py", line 219, in call_process_api
  File "gradio\blocks.py", line 1437, in process_api
  File "gradio\blocks.py", line 1123, in call_function
  File "gradio\utils.py", line 503, in async_iteration
  File "gradio\utils.py", line 496, in __anext__
  File "anyio\to_thread.py", line 33, in run_sync
  File "anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
  File "anyio\_backends\_asyncio.py", line 807, in run
  File "gradio\utils.py", line 479, in run_sync_iterator_async
  File "gradio\utils.py", line 629, in gen_wrapper
  File "ui\txt2img_ui.py", line 266, in txt2img_inf
  File "apps\stable_diffusion\src\pipelines\pipeline_shark_stable_diffusion_img2img.py", line 216, in generate_images
  File "apps\stable_diffusion\src\pipelines\pipeline_shark_stable_diffusion_utils.py", line 241, in produce_img_latents
  File "apps\stable_diffusion\src\schedulers\shark_eulerdiscrete.py", line 135, in scale_model_input
  File "shark\shark_inference.py", line 142, in __call__
    return self.shark_runner.run(function_name, inputs, send_to_host)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "shark\shark_runner.py", line 101, in run
    return get_results(
           ^^^^^^^^^^^^
  File "shark\iree_utils\compile_utils.py", line 538, in get_results
    result = compiled_vm[function_name](*device_inputs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "iree\runtime\function.py", line 137, in __call__
  File "iree\runtime\function.py", line 162, in _invoke
ValueError: Error invoking function: C:\actions-runner\w\SRT\SRT\c\runtime\src\iree\modules\hal\utils\buffer_diagnostics.c:225: INVALID_ARGUMENT; input 0 shape dimension 2 mismatch; expected 64 but have 96; expected shape `1x4x64x64`, actual shape `1x4x96x96`; while invoking native function hal.buffer_view.assert; while calling import;
[ 1]   native hal.buffer_view.assert:0 -
[ 0] bytecode module@0:236 -
xzuyn commented 1 year ago

ran into the following runtime error with the euler_scale_model_input submodel:

Yea, I noticed that too. It would work fine with 512x512, but 768x768 would break. DEIS and some others seemed to work.

DiffusionAllusion commented 10 months ago

Having this issue too, on AMD. Is there a workaround/fix?