Repository navigation
Cosmos3: one builder for the batched step's rows, so the warmup can't break boot #944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,14 @@ def __init__(self): | |
| self.proj_in = torch.nn.Linear(2, 2) | ||
| self.batched_calls = [] | ||
|
|
||
| # what the real step indexes per request; a warmup row missing one would raise here as it did on a server | ||
| REQ_KEYS = ("latents", "vision_timesteps", "rotary_cond", "rotary_uncond", "vision_token_shapes", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: |
||
| "vision_noisy_frame_indexes", "vision_mse_loss_indexes") | ||
|
|
||
| def denoise_step_batched(self, requests, label, attn): | ||
| for req in requests: | ||
| for key in self.REQ_KEYS: | ||
| req[key] | ||
| self.batched_calls.append((requests, label, attn)) | ||
| return [(None, None)] * len(requests) | ||
|
|
||
|
|
@@ -103,11 +110,12 @@ def test_warmup_compiles_runs_one_two_request_step_at_the_default_size(monkeypat | |
| t = _RecordingTransformer() | ||
| sub = Cosmos3DiTSubmodule(t, cfg) | ||
| built = [] | ||
| rotary = (torch.zeros(4, 2), torch.zeros(4, 2)) | ||
|
|
||
| def fake_static(ids, height, width, num_frames, fps, has_image_condition, device): | ||
| built.append((height, width, num_frames, has_image_condition)) | ||
| return { | ||
| "num_noisy_vision_tokens": 4, "vision_mrope_ids": torch.zeros(3, 4), | ||
| "num_noisy_vision_tokens": 4, "rotary": rotary, | ||
| "vision_token_shapes": [(1, 2, 2)], "vision_noisy_frame_indexes": [torch.zeros(1)], | ||
| "mse_gen_indexes": torch.arange(4), | ||
| } | ||
|
|
@@ -121,6 +129,8 @@ def fake_static(ids, height, width, num_frames, fps, has_image_condition, device | |
| [(requests, label, attn)] = t.batched_calls | ||
| assert len(requests) == 2 and label == submodules.CFG_BATCHED_LABEL | ||
| assert requests[0]["latents"].shape == sub._latent_shape(480, 832, 121) | ||
| # both branches take the statics' table, as a served window's rows do | ||
| assert requests[0]["rotary_cond"] is rotary and requests[1]["rotary_uncond"] is rotary | ||
| # the stand-in reads no plan and answers with the query's shape | ||
| q = torch.randn(5, 2, 3) | ||
| assert not attn.requires_kv_write and torch.equal(attn.run(q, k=q, v=q), torch.zeros_like(q)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This row is the fourth hand-built copy of
denoise_step_batched's input, beside the ones inforward_batched,_forward_batched_soundandforward_captured, so every change to what the step reads has to find all four. One builder next todenoise_step_batchedintransformer.py, called by all four with their statics or capture layout, should build these rows, so the warmup follows the step by construction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:
Cosmos3OmniTransformer.denoise_step_rowsits right above the step andwarmup_compiles,forward_batched,_forward_batched_soundandforward_capturedall build their rows with it, so a new input to the step changes its signature and every caller has to pass it. I fingerprinted each caller's rows before and after (keys in order, bytes, which statics object each value is) and they're identical, and the description says where each caller's inputs come from.