Skip to content
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

Add extrapolation to fork module #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Suad0
Copy link
Contributor

@Suad0 Suad0 commented Nov 8, 2024

No description provided.

// Extrapolate if input is outside known range
if input_lengths_sum < anals.first().unwrap().input_lengths.iter().sum::<usize>() {
let lhs = &anals[0];
let rhs = &anals[1];
Copy link
Owner

Choose a reason for hiding this comment

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

At this stage, there could be only a single analyzation in the vector. Therefore, this can panic

let rhs = &anals[1];
return self.extrapolate_and_execute(lhs, rhs, input_lengths_sum, cpu_op, gpu_op);
} else if input_lengths_sum > anals.last().unwrap().input_lengths.iter().sum::<usize>() {
let lhs = &anals[anals.len() - 2];
Copy link
Owner

Choose a reason for hiding this comment

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

same as above

@@ -81,6 +115,18 @@ impl<Mods> UseGpuOrCpu for Fork<Mods> {

let input_lengths_sum = input_lengths.iter().sum::<usize>();

// Extrapolate if input is outside known range
if input_lengths_sum < anals.first().unwrap().input_lengths.iter().sum::<usize>() {
Copy link
Owner

Choose a reason for hiding this comment

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

There is no chance to add new data points as the interpolation step takes any two analyzations (lhs, rhs) where the new analyzation (x) input size sum is lhs_input_sum <= x_input_sum <= rhs_input_sum.
Hence the max analyzations amount would be 2 ig

@@ -90,10 +136,14 @@ impl<Mods> UseGpuOrCpu for Fork<Mods> {

if input_lengths_sum >= input_lengths_lhs && input_lengths_sum <= input_lengths_rhs {
let new_cpu_dur = lhs.cpu_dur.as_secs_f32()
+ 0.5 * (rhs.cpu_dur.as_secs_f32() - lhs.cpu_dur.as_secs_f32());
+ (input_lengths_sum - input_lengths_lhs) as f32
/ (input_lengths_rhs - input_lengths_lhs) as f32
Copy link
Owner

Choose a reason for hiding this comment

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

could leave this factor at 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants