[API] Report FPS in a standardized way - #604
Conversation
Greptile SummaryThis PR standardizes model-step FPS reporting in benchmark artifacts.
Confidence Score: 4/5The PR is not safe to merge because deleting The FPS reporting implementation is covered by focused runner tests, and deleting the problematic Files Needing Attention: apps/t2v/t2v/testing.py Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Model step completes] --> B[Session runner measures elapsed time]
B --> C[MetricsOutputSink waits for results]
C --> D[Record elapsed seconds and frame count]
D --> E[Compute per-step FPS samples]
E --> F[Calculate p90 FPS]
F --> G[Write standardized JSON artifact]
|
|
|
||
|
|
||
| class _FrameInspector(OutputSink): | ||
| class _FrameInspector(MetricsOutputSink): |
There was a problem hiding this comment.
Metrics state is uninitialized
_FrameInspector now inherits MetricsOutputSink, but its constructor and open() method do not initialize the inherited _model_step_info field. check_t2v_model_impl passes this inspector to run_session, which calls the inherited new_model_step() for the first non-empty model step. That method tries to append to the missing field, raising AttributeError and failing the standard T2V test and real-model check paths. Initialize the inherited state through the base class or implement the new callback explicitly.
There was a problem hiding this comment.
This debug object can implement its own hacks, at the end of the day, it still conforms to our interface.
There was a problem hiding this comment.
I agree that _FrameInspector can have its own implementation; the issue is that it currently has no new_model_step implementation, so it inherits MetricsOutputSink.new_model_step. run_session now calls that method before each model result, and the inherited method accesses _model_step_info, which _FrameInspector.__init__ never initializes. It will therefore raise on the first model step. Either override new_model_step with a no-op/custom implementation, or initialize and use the inherited state. As written, it conforms to the old OutputSink interface, but not the new runtime contract introduced by the MetricsOutputSink annotation and callback.
| """ | ||
| if not step_results: | ||
| return | ||
| largest_chunk_size = max(result.frame_count for result in step_results) |
There was a problem hiding this comment.
do we have a case where the frame_count in the step_results are different?
Trying to understand why is this needed
There was a problem hiding this comment.
It is not needed, I realized we have this:
if frame_count <= 0 or any(item.frame_count != frame_count for item in chunk):
raise ValueError("Every channel in a chunk must have the same frame_count.")
```
| step_elapsed_s=step_elapsed_s, | ||
| ) | ||
| if metrics_output_sink is not None: | ||
| metrics_output_sink.new_model_step(step_elapsed_s, results) |
There was a problem hiding this comment.
the new_model_step function is essentially just recording the results with step_elapsed_s, right? The name seems confusing. Maybe name it record_model_step_elapsed_s() ?
|
Current design does not account for |
3e80b43 to
d9b2516
Compare
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
added |
d67f46b to
7eac488
Compare
|
/ok to test 7eac488 |
| # Since we are measuring "elapsed ms average", the cost of presenting | ||
| # all 8 at once is being measured via this wait. | ||
| for result in step_results: | ||
| result.wait_until_ready() |
There was a problem hiding this comment.
I understand we need to measure the model step(), but we need to be very careful and avoid this sync point in production (when not measuring the model.step()). This might hurt end to end performance.
There was a problem hiding this comment.
I suppose a more elegant solution exists here, and I should try to implement it.
|
we decided to take a different approach, and side-line this idea |
|
For a clearer justification: FPS has many different meanings for
For now we will just stick with |
resolves: #603
Extend
MetricsOutputSinkto report model step 'FPS' in a standardized way when trying to emit stats via--stats-path.We will generally try to present 'FPS of something' via model_step FPS since ui_step FPS is quite easy to raise (cheap to run ui_step, expensive to run model_step).