Spaces:
Running
on
Zero
Running
on
Zero
File size: 8,265 Bytes
87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 cb0b907 25daeff 4cd7f21 25daeff 4cd7f21 25daeff 4cd7f21 25daeff b4df47c 4cd7f21 b4df47c 4cd7f21 25daeff cb0b907 87c9ae9 cb0b907 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 4cd7f21 87c9ae9 4cd7f21 87c9ae9 af8665d 87c9ae9 1835c38 87c9ae9 1835c38 87c9ae9 af8665d 87c9ae9 af8665d 87c9ae9 af8665d 87c9ae9 1835c38 87c9ae9 1835c38 4cd7f21 87c9ae9 cb0b907 4cd7f21 87c9ae9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "7943b934",
"metadata": {},
"outputs": [],
"source": [
"%cd /home/ubuntu/Qwen-Image-Edit-Angles"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5de64216",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from matplotlib import pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "07aff18c",
"metadata": {},
"outputs": [],
"source": [
"from qwenimage.experiment import ExperimentConfig\n",
"from qwenimage.experiments.experiments_qwen import ExperimentRegistry\n",
"\n",
"\n",
"# experiment_names = ExperimentRegistry.keys()\n",
"experiment_names = [\n",
"\n",
" \"qwen_base\",\n",
" \"qwen_fa3\",\n",
" \"qwen_aot\",\n",
" \"qwen_fuse_aot\",\n",
" \"qwen_fa3_aot\",\n",
"\n",
" \"qwen_fbcache_052\",\n",
" \"qwen_fbcache_053\",\n",
" \"qwen_fbcache_054\",\n",
" \"qwen_fbcache_055\",\n",
"\n",
" \"qwen_fa3_aot_fp8\",\n",
" \"qwen_fa3_aot_fp8_fuse\",\n",
"\n",
" \"qwen_base_3step\",\n",
" \"qwen_base_2step\",\n",
" \"qwen_fa3_aot_int8_fuse_3step\",\n",
" \"qwen_fa3_aot_int8_fuse_2step\",\n",
"\n",
" \"qwen_lightning_lora\",\n",
" \"qwen_lightning_lora_2step\",\n",
" \"qwen_lightning_lora_3step\",\n",
" \"qwen_lightning_fa3_aot_int8_fuse_3step\",\n",
" \"qwen_lightning_fa3_aot_int8_fuse_2step\",\n",
" \"qwen_lightning_fa3_aot_fp8_fuse\",\n",
"\n",
"]\n",
"\n",
"report_dir = ExperimentConfig().report_dir\n",
"\n",
"all_results = []\n",
"for name in experiment_names:\n",
" csv_path = report_dir / f\"{name}.csv\"\n",
" \n",
" df = pd.read_csv(csv_path, index_col=0)\n",
" df['experiment'] = name\n",
" all_results.append(df)\n",
" print(f\"Loaded results for {name}: {len(df)} rows\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53cb7629",
"metadata": {},
"outputs": [],
"source": [
"all_results[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5bb86726",
"metadata": {},
"outputs": [],
"source": [
"combined_df = pd.concat(all_results, ignore_index=True)\n",
"print(f\"{combined_df.shape=}\")\n",
"print(f\"{combined_df.columns.tolist()=}\")\n",
"combined_df.head(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5fcd8c1a",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "fac9587f",
"metadata": {},
"outputs": [],
"source": [
"# profile_targets = [\"loop\", \"run_once\"]\n",
"profile_targets = {\n",
" \"loop\": \"equal\",\n",
" \"run_once\": \"contain\"\n",
"}\n",
"\n",
"for target, match_strategy in profile_targets.items():\n",
" if match_strategy == \"equal\":\n",
" plot_data = combined_df[combined_df['name'] == target].copy()\n",
" elif match_strategy == \"contain\":\n",
" plot_data = combined_df[combined_df['name'].str.contains(target, case=False, na=False)].copy()\n",
" else:\n",
" raise ValueError()\n",
" plot_data = plot_data.sort_values('mean', ascending=False)\n",
"\n",
" fig, ax = plt.subplots(figsize=(12, 6))\n",
" x_pos = range(len(plot_data))\n",
" max_time = plot_data['mean'].max()\n",
"\n",
" bars = ax.bar(x_pos, plot_data['mean'], yerr=plot_data['std'], \n",
" capsize=12, alpha=0.7, edgecolor='black')\n",
" ax.set_xlabel('Optimization Type', fontsize=12, fontweight='bold')\n",
" ax.set_ylabel('Time (s)', fontsize=12, fontweight='bold')\n",
" ax.set_title(f'Optimizations Comparison Over: {target}', \n",
" fontsize=14, fontweight='bold')\n",
" ax.set_xticks(x_pos)\n",
" ax.set_xticklabels([row['experiment'] for _, row in plot_data.iterrows()], \n",
" rotation=45, ha='right', fontsize=12)\n",
" ax.grid(axis='y', alpha=0.3)\n",
"\n",
"\n",
" for i, (idx, row) in enumerate(plot_data.iterrows()): \n",
" ax.text(i - 0.2, row['mean'] + 0.01, f\"{row['mean']:.3f}s\", \n",
" ha='center', va='bottom', fontsize=12)\n",
" \n",
" pct_decrease = ((max_time - row['mean']) / max_time) * 100\n",
" ax.text(i + 0.2, row['mean'] + 0.01, f\"(-{pct_decrease:.1f}%)\", \n",
" ha='center', va='bottom', fontsize=12, color='green')\n",
" \n",
" \n",
"\n",
" plt.tight_layout()\n",
"\n",
" plot_path = report_dir / f'{target}_performance_comparison.png'\n",
" plt.savefig(plot_path, dpi=300, bbox_inches='tight')\n",
"\n",
" plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eec1ec7e",
"metadata": {},
"outputs": [],
"source": [
"stack_targets = [\"Preprocessing\", \"Encode Prompt\", \"Prep gen\", \"loop\", \"pre decode\", \"vae.decode\", \"post process\", \"offload\"]\n",
"\n",
"\n",
"stack_data = combined_df[combined_df['name'].isin(stack_targets)].copy()\n",
"pivot_data = stack_data.pivot(index='experiment', columns='name', values='mean')\n",
"pivot_data = pivot_data[stack_targets]\n",
"pivot_data['total'] = pivot_data.sum(axis=1)\n",
"pivot_data = pivot_data.sort_values('total', ascending=False)\n",
"pivot_data = pivot_data.drop('total', axis=1)\n",
"\n",
"\n",
"fig, ax = plt.subplots(figsize=(14, 7))\n",
"pivot_data.plot(kind='bar', stacked=True, ax=ax, \n",
" colormap='viridis', edgecolor='black', capsize=12, alpha=0.7, width=0.8)\n",
"\n",
"\n",
"ax.set_xlabel('Optimization Type', fontsize=12, fontweight='bold')\n",
"ax.set_ylabel('Time (s)', fontsize=12, fontweight='bold')\n",
"ax.set_title('Pipeline Time Breakdown by Optimization', \n",
" fontsize=14, fontweight='bold')\n",
"ax.set_xticklabels(pivot_data.index, rotation=45, ha='right', fontsize=12)\n",
"ax.legend(title='Pipeline Stage', bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=10)\n",
"ax.grid(axis='y', alpha=0.3)\n",
"\n",
"max_time = pivot_data.sum(axis=1).max()\n",
"for i, (idx, row) in enumerate(pivot_data.iterrows()):\n",
" total = row.sum()\n",
" \n",
" ax.text(i - 0.2, total + 0.01, f'{total:.3f}s', \n",
" ha='center', va='bottom', fontsize=12, fontweight='bold')\n",
" \n",
" pct_decrease = ((max_time - total) / max_time) * 100\n",
" ax.text(i + 0.2, total + 0.01, f'(-{pct_decrease:.1f}%)', \n",
" ha='center', va='bottom', fontsize=12, color='green', fontweight='bold')\n",
"\n",
"plt.tight_layout()\n",
"\n",
"plot_path = report_dir / 'stacked_time_breakdown.png'\n",
"plt.savefig(plot_path, dpi=300, bbox_inches='tight')\n",
"\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db8bf253",
"metadata": {},
"outputs": [],
"source": [
"stack_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fd23a11b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b386ec5e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c2c15ce",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|