Skip to content

Add SMS-based partition pre-screener for inter frames - #5324

Open
YixinDu1 wants to merge 5 commits into
AOMediaCodec:av2-encfrom
YixinDu1:partition-pruning-sms
Open

Add SMS-based partition pre-screener for inter frames#5324
YixinDu1 wants to merge 5 commits into
AOMediaCodec:av2-encfrom
YixinDu1:partition-pruning-sms

Conversation

@YixinDu1

Copy link
Copy Markdown
Contributor

Add a unified SMS pre-screener (sms_unified_prune) that runs one MLP inference per square block before the partition search and uses the output to prune partition candidates.

Anchor: da53762
Test condition: CTC, RA, 33 frames, speed 4

RA:

+----------------+------+------+------+------+------+
| Class          |    Y |   Cb |   Cr | wAvg | Enc% |
+----------------+------+------+------+------+------+
| A1             | 0.01 | 0.35 |-0.09 | 0.02 | 96.3 |
| A2             | 0.14 | 0.14 | 0.27 | 0.14 | 95.5 |
| Average w/o B2 | 0.09 | 0.12 | 0.29 | 0.10 | 96.7 |
+----------------+------+------+------+------+------+

STATS_CHANGED

@YixinDu1
YixinDu1 marked this pull request as ready for review August 26, 2026 16:02

@urvangjoshi urvangjoshi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YixinDu1 : Thanks for the PR. The loss is slightly higher for A2, but there's speed-up as well.
Question: what are the numbers for lower resolution sets? I see that you disabled the speed feature for some lower resolutions.

Comment thread av2/encoder/partition_sms.c Outdated
Comment thread av2/encoder/partition_sms.h
@YixinDu1

YixinDu1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@YixinDu1 : Thanks for the PR. The loss is slightly higher for A2, but there's speed-up as well. Question: what are the numbers for lower resolution sets? I see that you disabled the speed feature for some lower resolutions.

Thanks for the comment. The loss for lower res is around 0.1x and there is around 2% speedup.

Comment thread av2/encoder/context_tree.h Outdated
Comment thread av2/encoder/partition_sms.c
Comment thread av2/encoder/partition_sms.c Outdated
Comment thread av2/encoder/partition_sms.c Outdated
Comment thread av2/encoder/partition_sms.c Outdated
Comment thread av2/encoder/partition_sms.c
Comment thread av2/encoder/partition_sms.c Outdated
Add a unified SMS pre-screener (sms_unified_prune) that runs one MLP
inference per square block before the partition search and uses the
output to prune partition candidates.

Anchor: da53762
Test condition: CTC, RA, 33 frames, speed 4

RA:
```
+----------------+------+------+------+------+------+
| Class          |    Y |   Cb |   Cr | wAvg | Enc% |
+----------------+------+------+------+------+------+
| A1             | 0.01 | 0.35 |-0.09 | 0.02 | 96.3 |
| A2             | 0.14 | 0.14 | 0.27 | 0.14 | 95.5 |
| Average w/o B2 | 0.09 | 0.12 | 0.29 | 0.10 | 96.7 |
+----------------+------+------+------+------+------+
```
STATS_CHANGED
…ward

Replace the bespoke mlp_forward() and softmax_inplace() with the
existing av2_nn_predict() + av2_nn_softmax() infrastructure.
Define per-bsize NN_CONFIG structs referencing the existing weight
arrays in partition_sms_weights.h.

Bump NN_MAX_NODES_PER_LAYER 128→256 to accommodate H1=128.
- context_tree.h: use ALL_PARTITION_TYPES instead of literal 10
- Add SMS_N_SPLIT_PARTS define; replace all hardcoded 4s
- Add feature description comment above SMS_FEAT_DIM
- Use local const min_dim for AVMMIN(cm->width, cm->height)
- Remove redundant ? 1 : 0 from boundary split indicators
- Pass reduce_prec=1 to av2_nn_predict for cross-platform consistency
- Use bool for horz_qualifies
@YixinDu1
YixinDu1 force-pushed the partition-pruning-sms branch from bc01ea3 to 409cfe8 Compare August 27, 2026 23:55
av2_nn_output_prec_reduce casts output[i]*512 to int, which overflows
for our ~35M logits and triggers UBSan. reduce_prec=0 is correct here
since logits are immediately consumed by av2_nn_softmax, which is
shift-invariant — cross-platform differences in raw logits cancel out
after normalization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants