-
Notifications
You must be signed in to change notification settings - Fork 93
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
Small Demo #303
Comments
Yup, and we could even set it up in the CI as a nightly. Do you have a project in mind to play "corpus" - if not, llvm itself could be it (if it wouldn't make things more confusing by playing 2 roles) |
I have an unusual situation where I have full time for the next six weeks to do this.
I can make this demo if you can help walk me through what I need to do.
What I can see is that we just need to compile a bunch of code with some special options and then give the byte code or whatever to your algorithms.
It should not need compiling all of chrome to at least demonstrate that.
Except for this last glitch I am having with EIGEN, I am able to build both compiler versions and use your tflite script.
So I am close to being able to do things with your prebuilt models and then I just need to make a simple example for the rest works.
I think getting tangled up in Fuschia and Chrome is not necessarily helpful if you can help walk me through what I need to do.
…________________________________
From: Mircea Trofin ***@***.***>
Sent: Monday, October 2, 2023 8:11 AM
To: google/ml-compiler-opt ***@***.***>
Cc: Reed Kotler ***@***.***>; Author ***@***.***>
Subject: Re: [google/ml-compiler-opt] Small Demo (Issue #303)
Yup, and we could even set it up in the CI as a nightly. Do you have a project in mind to play "corpus" - if not, llvm itself could be it (if it wouldn't make things more confusing by playing 2 roles)
—
Reply to this email directly, view it on GitHub<#303 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAFO4LKFOC2PTPK4KPO27ULX5LKQPAVCNFSM6AAAAAA5OIAZYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBTGIYDEOBRHA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Right, so we could use llvm itself as the corpus donor. Sticking to inlining for size - because regalloc would need profiles (and I think for end to end demo-ing, inline for size is a fine example). These are the steps:
|
thanks. i'll try these steps out.
…________________________________
From: Mircea Trofin ***@***.***>
Sent: Monday, October 2, 2023 9:43 AM
To: google/ml-compiler-opt ***@***.***>
Cc: Reed Kotler ***@***.***>; Author ***@***.***>
Subject: Re: [google/ml-compiler-opt] Small Demo (Issue #303)
Right, so we could use llvm itself as the corpus donor. Sticking to inlining for size - because regalloc would need profiles (and I think for end to end demo-ing, inline for size is a fine example). These are the steps:
* git clone llvm to, for instance, /work/llvm-project, cd /work/llvm-project, mkdir tflite-build && cd tflite-build. cmake will need to additionally have -DLLVM_ENABLE_PROJECTS=clang. The goal of this step is to build the clang we'll use for training, but we'll also use this clang for corpus collection. ninja clang llvm-objcopy (we need objcopy to extract the corpus)
* cd .. && mkdir corpus-build && cd corpus-build
* cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=/work/llvm-project/build/bin/clang++ -DCMAKE_C_COMPILER=/work/llvm-project/build/bin/clang -DCMAKE_CXX_FLAGS="-Xclang=-fembed-bitcode=all" -DCMAKE_C_FLAGS="-Xclang=-fembed-bitcode=all" ../llvm. We don't bother trying to say we build for size, the goal is just to get to a corpus. Note this generates a compile_commands.json in that build dir.
* ninja opt llc -> this is so we have some objects built.
* assuming you git clone-d ml-compiler-opt under /work/ml-compiler-opt: cd /work/ml-compiler-opt then PYTHONPATH=$PYTHONPATH:. python3 compiler_opt/tools/extract_ir.py --input /work/llvm-project/corpus-build/compile_commands.json --input_type json --llvm_objcopy_path /work/llvm-project/build/bin/llvm-objcopy --output_dir /tmp/corpus
* This extracts the corpus in /tmp/corpus, after that the training steps are the same as in the demos - i.e. collect a default trace.. all that.
—
Reply to this email directly, view it on GitHub<#303 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAFO4LLJ5GE4AN5UWBFWTZLX5LVJRAVCNFSM6AAAAAA5OIAZYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBTGM2TQNRYG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
What training performance could I expect if only using LLVM as the training corpus? |
What do you mean by "training performance": time it takes to train a model? Or model effectiveness (i.e. how much that model can shrink binaries)? Either way, I think @reedkotler did this recently (llvm as corpus), perhaps he can comment on both. Fuchsia's case discussed in the demo used to be half a day, but when we doubled the feature count, so did the training time. IIRC they get ~3% shrinkage in their overall image. |
Thanks for your instruction about using LLVM as a training corpus. I was able to run the inlining training. |
In general, we observed that having more modules from more diverse projects, during training, would help a model generalize better, but just like with manual heuristics, without trying it out, it's hard to tell what to expect for a specific case. |
Hello! What would be the steps for 'Deploying and using the new policy' when using LLVM itself as the corpus donor? I have hopefully trained the optimized model from the warmstart model, but in $OUTPUT_DIR I only see Any suggestions would be much appreciated. Thanks. |
let's focus on this first. How long did (My suspicion is that there may be an issue that makes each compile step fail => no actual training => no model) |
Indeed, |
OK, that's weird. Let's first make sure the use side of things - i.e. how the model is ingested and used - is set up right. Then we can look at the training side. I tried the published size model, here are my exact steps: For brevity, I used my paths - I have a git repo for llvm under
Check
I'd check again
so that's about 12% size savings. A possible gotcha: are you passing -mllvm -enable-ml-inliner=release? Are you building -Os or -Oz? (this latter is a weaker problem, the former is critical) |
What would be really helpful is a small test case that can train in 30 minutes on a modest machine. It does not have to produce a useful model but is something that one can see end to end without days of training. I'm willing to help make the test case if I can get some help.
The text was updated successfully, but these errors were encountered: