Skip to content

Pg/hpu bench fix #2355

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

Merged
merged 1 commit into from
May 28, 2025
Merged

Pg/hpu bench fix #2355

merged 1 commit into from
May 28, 2025

Conversation

pgardratzama
Copy link
Contributor

Issue is appearing when running bench with iter > 1, for example:
cargo run --profile devo --features=integer,internal-keycache,hpu-v80 --example hpu_bench -- --iter 10 --integer-w 64
because of usage of .next_back() measured latency is only the latency of the 1st operation.

No emergency to merge.

@pgardratzama pgardratzama requested a review from Bapt-Roux May 19, 2025 15:51
@cla-bot cla-bot bot added the cla-signed label May 19, 2025
Comment on lines 263 to 270
let res_hpu = (0..args.iter)
.map(|_i| {
let res = HpuRadixCiphertext::exec(&proto, iop.opcode(), &srcs_enc, &imms);
std::hint::black_box(&res);
res
})
.next_back()
.last()
.expect("Iteration must be greater than 0");
Copy link
Member

Choose a reason for hiding this comment

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

better to loop or collect first, iterators being greedy, without comment here it's easy to re introduce the bug

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in the last commit.
We now explicitly collect intermediate results in a vector

hpu_bench example was wrong for iter > 1 following clippy modifications.
NB: Vector is collect but intermediate value are explicitly drop to enable long-time stressed tests.
@Bapt-Roux
Copy link
Contributor

Commits were squashed and rebased on main.
@IceTDrinker could you have a look 🙏

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks !

Comment on lines +265 to +269
if i == (args.iter - 1) {
Some(res)
} else {
None
}
Copy link
Member

Choose a reason for hiding this comment

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

Just for the record, there could be a world where a very smart optimizer might trivialize this and not run some perf stuff, but thankfully today it works so all good :)

@Bapt-Roux Bapt-Roux merged commit 40f20b4 into main May 28, 2025
105 checks passed
@Bapt-Roux Bapt-Roux deleted the pg/hpu_bench_fix branch May 28, 2025 12:45
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.

4 participants