integer_adm: replace float sign check with integer comparison in adm_angle_flag#1468
integer_adm: replace float sign check with integer comparison in adm_angle_flag#1468GabrielBarros36 wants to merge 1 commit intoNetflix:masterfrom
Conversation
Replace the float cast and division used to check the sign of ot_dp with a direct integer comparison (ot_dp >= 0). The original code converted an int64 to float and divided by 4096.0 solely to test the sign, which is invariant under division by a positive constant. This eliminates an unnecessary int64-to-float promotion on the hot path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I think the logic is sound, but I do not measure a 2% speedup when I test. Any hints? |
@kylophone This was actually a little experiment in long-running agents. I hooked Claude Code up to an Amazon EC2 bare metal instance and told it to look for opportunities to speed VMAF up, then to implement + benchmark each idea. It ran all night and tested its ideas one by one. This was a really interesting workflow to test. There's some merit to "throwing tokens at the problem" as long as you have a measurable metric to improve and the correctness of each change is verifiable. Let me know if you'd like to talk more about this because I think it could produce significant results as long as we give the agent a solid "harness" - in this case, that'd mean a benchmarking workflow + a test suite comprehensive enough to catch any inconsistencies. That being said, I concluded doing this with VMAF isn't feasible because 1) I lack understanding of the project itself and I don't know how comprehensive the test suite is, and 2) most of the changes Claude produced were SIMD optimizations I don't fully understand and thus don't feel comfortable proposing. I know this change is correct, but the performance improvement is probably architecture-specific and I don't know if it'd be worth merging. The 2% number comes from the EC2 instance I let Claude spin up, but I don't even fully understand the settings it used and I don't know if it's reflective of how VA deploys VMAF in any given project. Later in the experiment I ended up forking VMAF and I put my PRs there to avoid polluting the PRs in this repo. Thank you for reviewing this! Let me know if there's anything here you want to follow up on, and I'd be happy to test this PR further or to close it! |
Summary
In
adm_decoupleandadm_decouple_s123, the first condition of theangle_flagcomputation was:This promotes an
int64tofloatand divides by a positive constant solely totest the sign. Since dividing by a positive constant preserves sign, this is
algebraically equivalent to:
The replacement eliminates an
int64→floatconversion and a float division onthe hot path. The second condition (magnitude comparison) is left in float to
preserve the original rounding behavior.
Benchmarks
Measured on AWS
c6a.metal(AMD EPYC 7R13, 2.65 GHz locked, turbo disabled,performance governor, pinned to 4 cores on NUMA node 0). Workload: 1080p 48-frame
YUV video scored with default VMAF model, 7 repetitions per configuration (CV <0.15%).
Correctness
feature extractors and models
xand positiveconstant
c,sign(x / c) == sign(x)Test plan
meson testin libvmaf builds and passes on x86-64