Skip to content

Commit 66d5f34

Browse files
committed
Fix pyink 23.10.0 formatting for files introduced in #443
1 parent d8ead5a commit 66d5f34

4 files changed

Lines changed: 44 additions & 52 deletions

File tree

src/maxdiffusion/generate_wan.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -390,17 +390,15 @@ def run(config, pipeline=None, filename_prefix="", commit_hash=None):
390390
vae_decode_total = trace.get("vae_decode", 0.0)
391391
vae_decode_tpu = trace.get("vae_decode_tpu", 0.0)
392392
vae_decode_post = vae_decode_total - vae_decode_tpu
393-
summary.extend(
394-
[
395-
f" {'─' * 40}",
396-
f" Conditioning: {trace.get('conditioning', 0.0):>7.1f}s",
397-
f" - VAE Encode: {trace.get('vae_encode', 0.0):>7.1f}s",
398-
f" Denoise Total: {trace.get('denoise_total', 0.0):>7.1f}s",
399-
f" VAE Decode: {vae_decode_total:>7.1f}s",
400-
f" - TPU Compute: {vae_decode_tpu:>7.1f}s",
401-
f" - Host Formatting: {vae_decode_post:>7.1f}s",
402-
]
403-
)
393+
summary.extend([
394+
f" {'─' * 40}",
395+
f" Conditioning: {trace.get('conditioning', 0.0):>7.1f}s",
396+
f" - VAE Encode: {trace.get('vae_encode', 0.0):>7.1f}s",
397+
f" Denoise Total: {trace.get('denoise_total', 0.0):>7.1f}s",
398+
f" VAE Decode: {vae_decode_total:>7.1f}s",
399+
f" - TPU Compute: {vae_decode_tpu:>7.1f}s",
400+
f" - Host Formatting: {vae_decode_post:>7.1f}s",
401+
])
404402
summary.append(f"{'=' * 50}")
405403
max_logging.log("\n".join(summary))
406404

src/maxdiffusion/pipelines/wan/wan_pipeline_2_1.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,13 @@ def run_inference_2_1(
290290
transformer_obj = nnx.merge(graphdef, sharded_state, rest_of_state)
291291

292292
# Compute RoPE once as it only depends on shape
293-
dummy_hidden_states = jnp.zeros(
294-
(
295-
latents.shape[0],
296-
latents.shape[2],
297-
latents.shape[3],
298-
latents.shape[4],
299-
latents.shape[1],
300-
)
301-
)
293+
dummy_hidden_states = jnp.zeros((
294+
latents.shape[0],
295+
latents.shape[2],
296+
latents.shape[3],
297+
latents.shape[4],
298+
latents.shape[1],
299+
))
302300
rotary_emb = transformer_obj.rope(dummy_hidden_states)
303301

304302
kv_cache = None

src/maxdiffusion/pipelines/wan/wan_pipeline_i2v_2p2.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -971,19 +971,17 @@ def scan_body(carry, t):
971971
# tracing both 14B branches per step and keeps the AOT cache usable.
972972
use_high_noise = bool(np.asarray(scheduler_state.timesteps)[step] >= np.asarray(boundary))
973973
branch = high_noise_branch if use_high_noise else low_noise_branch
974-
noise_pred, _ = branch(
975-
(
976-
latent_model_input,
977-
timestep,
978-
prompt_embeds_combined,
979-
image_embeds_combined,
980-
kv_cache_high,
981-
kv_cache_low,
982-
rotary_emb,
983-
encoder_attention_mask_high,
984-
encoder_attention_mask_low,
985-
)
986-
)
974+
noise_pred, _ = branch((
975+
latent_model_input,
976+
timestep,
977+
prompt_embeds_combined,
978+
image_embeds_combined,
979+
kv_cache_high,
980+
kv_cache_low,
981+
rotary_emb,
982+
encoder_attention_mask_high,
983+
encoder_attention_mask_low,
984+
))
987985
noise_pred = jnp.transpose(noise_pred, (0, 2, 3, 4, 1))
988986
latents, scheduler_state = scheduler.step(scheduler_state, noise_pred, t, latents).to_tuple()
989987

src/maxdiffusion/tests/aot_cache_test.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,23 @@ def test_signature_deterministic_across_processes(self):
137137
import subprocess
138138
import sys
139139

140-
snippet = "\n".join(
141-
(
142-
"import os",
143-
"os.environ['JAX_PLATFORMS'] = 'cpu'",
144-
"import jax",
145-
"import jax.numpy as jnp",
146-
"from flax import nnx",
147-
"from maxdiffusion import aot_cache",
148-
"",
149-
"class T(nnx.Module):",
150-
" def __init__(self, rngs):",
151-
" self.lin = nnx.Linear(4, 4, rngs=rngs)",
152-
"",
153-
"graphdef, state = nnx.split(T(nnx.Rngs(0)))",
154-
"sig = aot_cache._dynamic_signature(",
155-
" (graphdef, state.to_pure_dict(), jnp.ones((2, 4))), {})",
156-
"print(sig)",
157-
)
158-
)
140+
snippet = "\n".join((
141+
"import os",
142+
"os.environ['JAX_PLATFORMS'] = 'cpu'",
143+
"import jax",
144+
"import jax.numpy as jnp",
145+
"from flax import nnx",
146+
"from maxdiffusion import aot_cache",
147+
"",
148+
"class T(nnx.Module):",
149+
" def __init__(self, rngs):",
150+
" self.lin = nnx.Linear(4, 4, rngs=rngs)",
151+
"",
152+
"graphdef, state = nnx.split(T(nnx.Rngs(0)))",
153+
"sig = aot_cache._dynamic_signature(",
154+
" (graphdef, state.to_pure_dict(), jnp.ones((2, 4))), {})",
155+
"print(sig)",
156+
))
159157
outs = [
160158
subprocess.run(
161159
[sys.executable, "-c", snippet],

0 commit comments

Comments
 (0)