@@ -130,6 +130,10 @@ def load_or_generate_latents(config):
130130 """
131131 Loads saved latents if use_latents is True, otherwise generates random latents.
132132 """
133+ if isinstance (config , dict ):
134+ from types import SimpleNamespace
135+ config = SimpleNamespace (** config )
136+
133137 batch_size = config .batch_size
134138 height = config .height
135139 width = config .width
@@ -186,10 +190,21 @@ def get_qwen3_models(repo_id="black-forest-labs/FLUX.2-klein-4B"):
186190 """
187191 global _tokenizer , _text_encoder
188192 if _tokenizer is None :
193+ import os
189194 import torch
190195 from transformers import Qwen2TokenizerFast , Qwen3ForCausalLM
191196
192- print (f"Loading Qwen3 models from cached repo: { repo_id } ..." )
197+ # Resolve absolute local path from HF cache if it exists to bypass buggy from_pretrained resolving
198+ hf_home = os .environ .get ("HF_HOME" , os .path .expanduser ("~/.cache/huggingface" ))
199+ cache_dir = os .path .join (hf_home , "hub" , f"models--{ repo_id .replace ('/' , '--' )} " , "snapshots" )
200+ if os .path .exists (cache_dir ):
201+ snapshots = os .listdir (cache_dir )
202+ if snapshots :
203+ snapshot_dir = os .path .join (cache_dir , snapshots [0 ])
204+ print (f"Detected local cache directory: { snapshot_dir } " )
205+ repo_id = snapshot_dir
206+
207+ print (f"Loading Qwen3 models from repo path: { repo_id } ..." )
193208 try :
194209 _tokenizer = Qwen2TokenizerFast .from_pretrained (repo_id , local_files_only = True )
195210 except Exception :
@@ -657,6 +672,7 @@ def main(argv):
657672 dtype = jnp .bfloat16 if config .weights_dtype == "bfloat16" else jnp .float32 ,
658673 weights_dtype = jnp .bfloat16 if config .weights_dtype == "bfloat16" else jnp .float32 ,
659674 attention_kernel = config .attention ,
675+ scale_shift_order = getattr (config , "scale_shift_order" , "shift_scale" ),
660676 )
661677
662678 # 5b. Instantiate JAX FlaxAutoencoderKL VAE
0 commit comments