-
Notifications
You must be signed in to change notification settings - Fork 144
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 an example of Segment Anything Model [Inference] #814
base: main
Are you sure you want to change the base?
Conversation
@regisss |
model.to("hpu") | ||
|
||
with torch.no_grad(), autocast: | ||
for i in range(args.warmup): |
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.
can we change this warmup step similar to https://github.com/huggingface/optimum-habana/blob/main/optimum/habana/transformers/trainer.py#L881?
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.
That may not apply to this case. The code in the link is for 'training'. There are some variables dedicated for training.
For example: args.gradient_accumulation_steps , epoch * steps_in_epoch
These should not be included in this 'inference' example.
model.to("hpu") | ||
|
||
with torch.no_grad(), autocast: | ||
for i in range(args.warmup): |
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.
same here.
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.
Replied above.
@cfgfung Can you please provide GPU benchmark and add ci tests? |
Sure. Is there any reference for the CI test? This is just a validated example. I checked another merged example (2f55de3) and that does not require CI. GPU Benchmark: |
28a2549
to
144c499
Compare
Thanks for the review. I have renamed the test file and add few lines of codes to the makefile for the CI tests. |
Could you delete old file : test_modelenabling.py? Also I ran your tests on the latest, and I'm getting this error on the last test. Do you see this passing on Docker 1.15.0? FAILED tests/test_image_segmentation.py::GaudiSAMTester::test_no_latency_regression_bf16 - AssertionError: 81.58655166625977 not greater than or equal to 93.97604942321777 |
|
||
processor = SamProcessor.from_pretrained(args.model_name_or_path) | ||
model = SamModel.from_pretrained(args.model_name_or_path) | ||
|
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.
Instead have this code specific to SAM model, can you use AutoProcessor, AutoModel and have this script generic?
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.
Also, plz remove this specific SAM folder(we don't have specific model folder in all examples), and move the script under object-segmentation/
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.
Sure. These two are addressed in the new commit.
Removed the file. |
@cfgfung can you merge your change to the latest baseline? |
455d728
to
5f7b15d
Compare
Hi, |
@cfgfung can you rebase and provide the test result on latest? |
…tation. Used Automodel and related processor to replace model-specific API. Improved the testing logic.
ea58674
to
b398475
Compare
Hi, I have applied rebase and ran the tests. |
What does this PR do?
Add an example code of SegmentAnythingModel using Graph mode and BF16.
Original FP32:
n_iterations: 20
Total latency (ms): 10380.430936813354
Average latency (ms): 519.0215468406677
Enabled graph mode and BF16:
n_iterations: 20
Total latency (ms): 1639.5680904388428
Average latency (ms): 81.97840452194214
Before submitting