Views
No views yet
1Python 3.9.20
2torch 2.7.0
3torchvision 0.22.0
4transformers 4.53.1
5diffusers 0.32.11Z-Image-Turbo/
2├── original_onnx/ # Exported ONNX models (original format)
3│ ├── vae_decoder_simp_slim.onnx
4│ ├── vae_encoder_simp_slim.onnx
5│ └── z_image_transformer_body_only_simp_slim.onnx
6├── text_encoder_axmodel/ # Text encoder models in axmodel format
7│ ├── model.embed_tokens.weight.npy
8│ ├── qwen3_p128_l0_together.axmodel
9│ ├── qwen3_p128_l1_together.axmodel
10│ └── ... (36 layer models for Qwen3)
11├── transformer_axmodel/ # Transformer subgraph models in axmodel format
12│ ├── auto_00_model_layers_29_Add_4_output_0_to_sample_auto.axmodel
13│ ├── cfg_00_timestep_to_model_t_embedder_mlp_mlp_2_Gemm_output_0_config.axmodel
14│ └── ... (compiled subgraph models)
15├── transformer_onnx/ # Transformer models in ONNX format
16├── vae_model/ # VAE models (both ONNX and axmodel formats)
17├── VideoX-Fun/ # Main conversion and inference code
18└── README.md # This documentationVideoX-Fun directory:1git clone https://huggingface.co/AXERA-TECH/Z-Image-Turbo
2cd Z-Image-Turbo/VideoX-Fun1python scripts/z_image/export_transformer_body_onnx.py \
2 --output onnx-models-512x512/z_image_transformer_body_only_512x512.onnx \
3 --height 512 --width 512 --sequence-length 128 \
4 --latent-downsample-factor 8 \
5 --dtype fp32 \
6 --skip-slimImportant: Before exporting to ONNX format, you need to download the complete Z-Image-Turbo model from Tongyi-MAI/Z-Image-Turbo and place it in themodels/Diffusion_Transformer/directory. This repository only provides pre-compiled models and inference code for deployment on AXERA hardware.
--output: Output path for the ONNX model--height, --width: Target image dimensions (512x512)--sequence-length: Maximum sequence length for text embeddings (128 tokens)--latent-downsample-factor: VAE downsample factor (8x)--dtype: Data type (fp32 for highest accuracy)--skip-slim: Skip ONNX simplification (optional)Note: If you don't use--skip-slim, the model will be automatically simplified and the output will be named:z_image_transformer_body_only_512x512_simp_slim.onnx
1python ./examples/z_image_fun/collect_onnx_inputs.py \
2 --model_name models/Diffusion_Transformer/Z-Image-Turbo/ \
3 --output_dir transformer_body_only_512x512_simp_slim/calibration \
4 --height 512 --width 512 \
5 --max_sequence_length 1281python ./scripts/split_onnx_by_subconfig.py \
2 --model ./onnx-models-512x512/z_image_transformer_body_only_512x512_simp_slim.onnx \
3 --config ./pulsar2_configs/transformers_subgraph_512x512.json \
4 --output-dir ./transformers_body_only_512_512_split_onnx \
5 --verify \
6 --input-data ./transformer_body_only_512x512_simp_slim/calibration/transformer_inputs_prompt000_step00.npy \
7 --providers CPUExecutionProvidertransformers_subgraph_512x512.json) defines the splitting strategy, determining how the model is partitioned into smaller, manageable pieces that fit within the NPU's constraints.1python examples/z_image_fun/collect_subgraph_inputs.py \
2 --onnx ./onnx-models-512x512/z_image_transformer_body_only_512x512_simp_slim.onnx \
3 --subgraph-config ./pulsar2_configs/transformers_subgraph_512x512.json \
4 --output-dir ./transformer_body_only_512x512_simp_slim/subgraph-calib \
5 --tar-list-file ./transformer_body_only_512x512_simp_slim/subgraph-calib/paths.txt \
6 --skip-existing1python examples/z_image_fun/collect_subgraph_inputs.py \
2 --onnx ./onnx-models-1728x992/z_image_transformer_body_only_1728x992_simp_slim.onnx \
3 --subgraph-config ./pulsar2_configs/transformers_subgraph_1728x992.json \
4 --output-dir ./transformer_body_only_1728x992_simp_slim/subgraph-calib \
5 --tar-list-file ./transformer_body_only_1728x992_simp_slim/subgraph-calib/paths.txt \
6 --sample-size 1728 992 \
7 --max-seq-len 2561python ./scripts/generate_subgraph_configs.py \
2 --tar-list-file ./transformer_body_only_512x512_simp_slim/subgraph-calib/paths.txt \
3 --output-config-dir pulsar2_configs/subgraphs_512x512Important: After generating the sub-ONNX files, you need to apply ONNX simplification (onnxslim) to each subgraph for optimal performance.
1./compile_all_subgraphs.sh \
2 --onnx-dir ./transformers_body_only_512_512_split_onnx \
3 --config-dir pulsar2_configs/subgraphs_512x512 \
4 --output-base-dir ./compiled_transformers_body_only_512x512/out_all \
5 --final-output-dir ./compiled_transformers_body_only_512x512/out_finalout_all: Contains compilation logs and intermediate files for all subgraphsout_final: Contains only the successfully compiled axmodel files, ready for deployment1python scripts/z_image_fun/export_vae_onnx.py \
2 --model-root models/Diffusion_Transformer/Z-Image-Turbo/ \
3 --height 512 --width 512 \
4 --encoder-output onnx-models-512x512/vae_encoder.onnx \
5 --decoder-output onnx-models-512x512/vae_decoder.onnx \
6 --dtype fp32 \
7 --save-calib-inputs \
8 --calib-dir onnx-calibration-512x512 \
9 --skip-ort-check--model-root: Path to the Z-Image-Turbo model--encoder-output, --decoder-output: Output paths for the encoder and decoder ONNX models--save-calib-inputs: Save calibration inputs for quantization--calib-dir: Directory to store calibration data--skip-ort-check: Skip ONNX Runtime validation (useful when ORT has compatibility issues)pulsar2_configs/vae_decoder.json1pulsar2 build \
2 --output_dir ./compiled_output_vae_decoder \
3 --config pulsar2_configs/vae_decoder.json \
4 --npu_mode NPU3 \
5 --input onnx-models/vae_decoder_simp_slim.onnx \
6 --target_hardware AX650--output_dir: Output directory for compiled models--config: Path to the compilation configuration file--npu_mode: NPU mode (NPU3 for maximum performance on AX650N)--target_hardware: Target hardware platform (AX650)1python3 examples/z_image_fun/launcher_axmodel.py \
2 --transformer-config pulsar2_configs/transformers_subgraph.json \
3 --transformer-subgraph-dir ../transformer_axmodel \
4 --vae-axmodel ../vae_model/vae_decoder.axmodel--transformer-config: Configuration file that defines the subgraph structure--transformer-subgraph-dir: Directory containing all compiled transformer subgraph axmodels--vae-axmodel: Path to the compiled VAE decoder axmodel1root@ax650 Z-Image-Turbo/VideoX-Fun $ python3 examples/z_image_fun/launcher_axmodel.py \
2 --transformer-config pulsar2_configs/transformers_subgraph.json \
3 --transformer-subgraph-dir ../transformer_axmodel \
4 --vae-axmodel ../vae_model/vae_decoder.axmodel
5
6[INFO] Available providers: ['AxEngineExecutionProvider']
7/root/yongqiang/push_hugging_face/Z-Image-Turbo/VideoX-Fun/videox_fun/dist/wan_xfuser.py:22: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
8 @amp.autocast(enabled=False)
9...
10/root/yongqiang/push_hugging_face/Z-Image-Turbo/VideoX-Fun/videox_fun/models/wan_audio_injector.py:114: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
11 @amp.autocast(enabled=False)
12/root/yongqiang/push_hugging_face/Z-Image-Turbo/VideoX-Fun/videox_fun/models/wan_transformer3d_s2v.py:55: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
13 @amp.autocast(enabled=False)
142026-01-15 15:55:55.577 | INFO | __main__:main:425 - 使用的 prompt: sunrise over alpine mountains, low clouds in valleys, god rays, ultra-detailed landscape
15`torch_dtype` is deprecated! Use `dtype` instead!
16Loading checkpoint shards: 100%|████████████████████████████████████████████████████████| 3/3 [00:01<00:00, 2.26it/s]
17The module name (originally ) is not a valid Python identifier. Please rename the original module to avoid import issues.
18^@^@^@[INFO] Using provider: AxEngineExecutionProvider
19[INFO] Chip type: ChipType.MC50
20[INFO] VNPU type: VNPUType.DISABLED
21[INFO] Engine version: 2.12.0s
22[INFO] Model type: 2 (triple core)
23[INFO] Compiler version: 5.1-patch1-dirty 5c5e711b-dirty
24AX Denoising: 0%| | 0/9 [00:00<?, ?it/s][INFO] Using provider: AxEngineExecutionProvider
25[INFO] Model type: 2 (triple core)
26[INFO] Compiler version: 5.1-patch1-dirty 5c5e711b-dirty
272026-01-15 15:58:44.111 | INFO | __main__:_get_session:301 - 加载子图 session: cfg_00 from cfg_00_timestep_to_model_t_embedder_mlp_mlp_2_Gemm_output_0_config.axmodel
28[INFO] Using provider: AxEngineExecutionProvider
29[INFO] Model type: 2 (triple core)
30[INFO] Compiler version: 5.1-patch1-dirty 5c5e711b-dirty
312026-01-15 15:58:48.882 | INFO | __main__:_get_session:301 - 加载子图 session: cfg_01 from cfg_01_prompt_embeds_to_model_Slice_1_output_0_config.axmodel
32[INFO] Using provider: AxEngineExecutionProvider
33[INFO] Model type: 2 (triple core)
34[INFO] Compiler version: 5.1-patch1-dirty 5c5e711b-dirty
35...
362026-01-15 16:00:08.612 | INFO | __main__:_get_session:301 - 加载子图 session: cfg_30 from cfg_30_model_layers_26_Add_4_output_0_to_model_layers_27_Add_4_output_0_config.axmodel
37[INFO] Using provider: AxEngineExecutionProvider
38[INFO] Model type: 2 (triple core)
39[INFO] Compiler version: 5.1-patch1 5c5e711b
402026-01-15 16:00:11.179 | INFO | __main__:_get_session:301 - 加载子图 session: cfg_31 from cfg_31_model_layers_27_Add_4_output_0_to_model_layers_28_Add_4_output_0_config.axmodel
41[INFO] Using provider: AxEngineExecutionProvider
42[INFO] Model type: 2 (triple core)
43[INFO] Compiler version: 5.1-patch1 5c5e711b
442026-01-15 16:00:13.868 | INFO | __main__:_get_session:301 - 加载子图 session: cfg_32 from cfg_32_model_layers_28_Add_4_output_0_to_model_layers_29_Add_4_output_0_config.axmodel
45AX Denoising: 22%|███████████████▎ | 2/9 [01:36<04:45, 40.84s/it]AX Denoising: 100%|█████████████████████████████████████████████████████████████████████| 9/9 [02:20<00:00, 15.60s/it]
46[INFO] Using provider: AxEngineExecutionProvider
47[INFO] Model type: 2 (triple core)
48[INFO] Compiler version: 5.1-patch1 5c5e711b
492026-01-15 16:01:06.972 | INFO | __main__:main:537 - AXModel 推理完成,结果保存到 /root/yongqiang/push_hugging_face/Z-Image-Turbo/VideoX-Fun/samples/z-image-t2i-axmodel/z_image_axmodel_2.png1ENABLE_COMPILER=0 DUMP_FRONTEND_GRAPH=1 \
2pulsar2 build \
3 --output_dir ./compiled_output_trans_body_only_frontend \
4 --config pulsar2_configs/config_controlnet.json \
5 --npu_mode NPU3 \
6 --input ../original_onnx/z_image_transformer_body_only_simp_slim.onnx \
7 --target_hardware AX6501pulsar2 build \
2 --input compiled_output_trans_body_only_use_calibration/quant/quant_axmodel.onnx \
3 --model_type QuantAxModel \
4 --output_dir compiled_subgraph_from_quant_onnx \
5 --output_name transformers.axmodel \
6 --config pulsar2_configs/transformers_subgraph.json \
7 --target_hardware AX650 \
8 --npu_mode NPU3