Gate partition ML/pruning in fast two pass partitions - #5317
Conversation
|
@yeqing-wu : I have a general question related to the fast two pass method: Reason for asking:
Given that fast two pass is enabled for speed >= 3 on that commit, I'm trying to understand something isn't fundamentally broken with this feature in combination with extended partitions. It's more important to double check this, as you move the feature to speed 2. Note: On commit 2abcfff (~1 week ago), the behavior was as expected (gain at both speed 2 and 4) |
|
Hi @urvangjoshi, thanks for your information. I haven’t conducted any special tests with the extended partitions turned on. All my tests are based on the default speed features in the av2-enc branch. Before I run the tests, let me confirm a few things:
Thanks |
Correct. For my tests, I basically moved this speed feature to speed 5 (to test gains on speed 2, 3 and 4).
The coding gains when enabling ext-partitions (on top of commit 2abcfff) were as follows (33 frames RA, all classes without B2):
The ratio isn't good enough to directly make this change, but I'm thinking about possible pruning methods to get some of the gains.
|
|
Got it. I can run some tests with sf->part_sf.disable_ext_partitions = false. By the way, when part_sf.disable_ext_partitions is set to true, how many partition shapes would be disabled? There’s no comment in the code explaining this, so could you please elaborate on it? Does it disable all 3-ways and 4-ways partitions? |
This will only enable the HORZ_3 / VERT_3 (that is, H shaped) partitions. |
|
@urvangjoshi, after reading the code of the extended partition, I now understand why disable_ext_partitions = false doesn't help and in fact hurts performance. The same issue affects both the slow and the fast two-pass partition. The reasons are as follows:
So extended partitions are exercised very rarely, while enabling them adds block-level signaling cost. The cost of signaling the partition shape isn't offset by the residual savings. This is naturally even worse in the fast |
Thanks for digging through the details. Anyway, we'll have to keep this in mind going forward. Can you add a comment for this in the code -- wherever you feel appropriate? |
29862b1 to
f2ccd3e
Compare
|
@urvangjoshi sure, add these notes above the definition of disable_ext_partitions. |
|
Hi All, if you have time, could you please help review this PR? |
|
@yeqing-wu : Looking at the speed 2 numbers:
The ratio for A2 is ~30, which seems borderline. Meanwhile, the benefit for speed >= 3 is clear. [Note that speed 2 is already much worse than speed 1, btw]. Feel free to chime in @leolzhao @yunqingwang1 |
@leolzhao @yunqingwang1 @jingninghan, what are your thoughts? The overall tradeoff is quite good, with a coding loss of 0.2% and a significant reduction in encoding time of 16%. This results in a ratio of 80x, which is much higher than the required minimum bar 30x ratio. If you really have concerns about the trade-off of class A2 in speed 2, another solution is to apply this only to class A1 for speed 2. It offers a -0.65% coding gain and still achieves a 16% reduction in encoding time, which are both significant advantages for class A1 in speed 2. Thanks |
Enabling for A1 only at speed 2 sounds good! |
|
Let’s wait for others’ comments. If they’re okay with only enabling class A1 in speed 2, I’m fine with that. My only concern is that having so many customized settings for different classes would make the encoder extremely complex, but this is just my personal opinion. |
I agree with Urvang that we can turn on this speed feature for speed >=3 for now. If the trade off for speed = 2 is further improved, then we can turn it on. |
Okay, then I’ll turn it on only for class A1 in speed 2, as it offers a coding gain of -0.65% and saves 16% of encoding time. For class A2 in speed 2, given the concerns about the tradeoff, I’ll disable it and save it for future improvements. |
f2ccd3e to
f8ae855
Compare
|
Done. Add the following constraints: @urvangjoshi and @leolzhao, could you please help review it? |
Looks good. Pls update the PR description as well. |
|
Also updated the commit message to reflect this constraint on speed 2. |
|
@urvangjoshi, I have a question. Is there a way to automatically sync the PR conversation message with the change in the commit message? If not, it would be tedious to manually modify the PR conversation message with the commit message. |
I don't believe so. |
|
The pipeline tests are queueing now, do I need to do anything to proceed them? |
We have to just wait unfortunately (you may have seen my email about 4 runners causing the queueing). |
This newly activates fast two pass partition for speed=2, while
improving speed-quality ratio for speed=3/4. At speed=2 it is turned
on only for class A1 (2160p and above). Class A2 (2K) lost coding
efficiency at speed=2, so we leave it off there. Speeds 3 and 4 are
not changed and stay on for every resolution.
Some of the partition ML/pruning schemes interact poorly with the
fast two-pass partition search, so skip them in the dry pass and on
trusted wet-pass blocks. The full policy across regimes:
* FAST dry pass: disabled. Shape is picked from reduced-tool
RD, and the dry pass is already fast.
* FAST wet pass, forced: disabled. Partition is already fixed by the
dry-pass template; the decision is discarded.
* FAST wet pass, reopened: enabled. Block is genuinely searched.
* CONSERVATIVE / one-pass: enabled. Predicate is inert on this path.
Anchor: commit 7361d54
Speed 4 (cpu-used=4): FG16 CTC (33 frames, class A1 and A2, RA)
Speed 3 (cpu-used=3): FG16 CTC (33 frames, class A1 and A2, RA)
Speed 2 (cpu-used=2): FG16 CTC (33 frames, class A1 and A2, RA)
```
1) Speed 4 (cpu-used=4)
+------------+-------+-------+-------+-------+------+------+
| Class | Y | Cb | Cr | wAvg | Enc% | Dec% |
+------------+-------+-------+-------+-------+------+------+
| A1 | -0.73 | 0.26 | -0.05 | -0.66 | 106 | 101 |
| A2 | -0.49 | 0.22 | 0.20 | -0.43 | 105 | 101 |
| Avg w/o B2 | -0.56 | 0.23 | 0.12 | -0.50 | 105 | 101 |
+------------+-------+-------+-------+-------+------+------+
2) Speed 3 (cpu-used=3)
+------------+-------+-------+-------+-------+------+------+
| Class | Y | Cb | Cr | wAvg | Enc% | Dec% |
+------------+-------+-------+-------+-------+------+------+
| A1 | -0.75 | 0.08 | 0.17 | -0.68 | 106 | 101 |
| A2 | -0.47 | 0.18 | -0.15 | -0.43 | 104 | 100 |
| Avg w/o B2 | -0.55 | 0.15 | -0.05 | -0.51 | 105 | 100 |
+------------+-------+-------+-------+-------+------+------+
3) Speed 2 (cpu-used=2)
+------------+-------+-------+-------+-------+------+------+
| Class | Y | Cb | Cr | wAvg | Enc% | Dec% |
+------------+-------+-------+-------+-------+------+------+
| A1 | -0.50 | -2.10 | -2.72 | -0.65 | 84 | 87 |
| A2 | 0.46 | 1.97 | 1.60 | 0.56 | 83 | 95 |
| Avg w/o B2 | 0.17 | 0.76 | 0.32 | 0.20 | 84 | 93 |
+------------+-------+-------+-------+-------+------+------+
```
STATS_CHANGED
f8ae855 to
a51fc80
Compare



This newly activates fast two pass partition for speed=2, while improving speed-quality ratio for speed=3/4. At speed=2 it is turned on only for class A1 (2160p and above). Class A2 (2K) lost coding efficiency at speed=2, so we leave it off there. Speeds 3 and 4 are not changed and stay on for every resolution.
Some of the partition ML/pruning schemes interact poorly with the fast two-pass partition search, so skip them in the dry pass and on trusted wet-pass blocks. The full policy across regimes:
RD, and the dry pass is already fast.
dry-pass template; the decision is discarded.
Anchor: commit 7361d54
Speed 4 (cpu-used=4): FG16 CTC (33 frames, class A1 and A2, RA)
Speed 3 (cpu-used=3): FG16 CTC (33 frames, class A1 and A2, RA)
Speed 2 (cpu-used=2): FG16 CTC (33 frames, class A1 and A2, RA)
STATS_CHANGED