-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Separate benchmarks by enabled features #1538
Conversation
candle-core/benches/bench_utils.rs
Outdated
} | ||
} | ||
|
||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this allow pragma? Maybe there is a way to avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I don't know a way to get around it. Criterion doesn't run the code in the same way as the standard rust testing framework, so it doesn't register as being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I guess you googled a bit on the criterion side and haven't found anything (I haven't checked), could you add a comment to explain why these are needed? (and link to any criterion resource that would document this if any)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, cargo isn't complaining about unused code anymore 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I tried after cargo clean and still get no warnings 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is related to the /benches
folder file structure https://users.rust-lang.org/t/how-to-properly-add-test-cases-for-benches/102859/4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the warnings still present? If they are still there for any of you I'll try a different approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Just remove the utils file. Bench will walk all files including the utils which is why it will complain. Just but them in the core file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "core" file, do you mean matmul.rs
?
I was thinking we could have several benchmarks matmul.rs
, random.rs
, etc.
If I place these in their own module and load them from a bench_main.rs
file we won't be able to specify which benchmark to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why we don't have both benches when compiling with --features metal
.
Is it hard to change it so we can have both (we can skip the bench on metal when metal is not active, but not having CPU bench when metal is active feels odd)
} | ||
|
||
pub(crate) fn bench_name<S: Into<String>>(name: S) -> String { | ||
format!("{}_{}", device_variant(), name.into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we derive this name from the actual device, not do guesswork on the features enabled (keep the guessing for MKL/Accelerate I don't know how to do it for those).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the exact same guesswork as how I obtain the actual device, so technically it won't be less guessy.
pub(crate) fn device() -> Result<Device> {
if cfg!(feature = "metal") {
Device::new_metal(0)
} else if cfg!(feature = "cuda") {
Device::new_cuda(0)
} else {
Ok(Device::Cpu)
}
}
It does make it more consistent though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated now 😊
Ah, I think I understand. I'll look into it. |
It's more about consistency. In general features should be additive. This is not the case for The tests also follow that behavior. |
For kernels it's generally speaking closer to replacing certain parts than adding new ones, is it not? |
No it's not. adding the metal features, enables a user to use the |
Right you are! 😊 Updated the code. |
With this results from
--features=metal
won't interfere with results from--features=accelerate
etc.