optimum-habana icon indicating copy to clipboard operation
optimum-habana copied to clipboard

Add an example of Segment Anything Model [Inference]

Open cfgfung opened this issue 11 months ago • 8 comments

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

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [ ] Did you make sure to update the documentation with your changes?
  • [ ] Did you write any new necessary tests?

cfgfung avatar Mar 18 '24 18:03 cfgfung

@regisss This is a validated model and this is an example script for users. No core code has been changed.

cfgfung avatar Mar 21 '24 17:03 cfgfung

@cfgfung Can you please provide GPU benchmark and add ci tests?

yeonsily avatar Mar 21 '24 21:03 yeonsily

@cfgfung Can you please provide GPU benchmark and add ci tests?

@yeonsily

Sure. Is there any reference for the CI test? This is just a validated example. I checked another merged example (https://github.com/huggingface/optimum-habana/commit/2f55de3f9ad23a853768c16029c455ee11b0e515) and that does not require CI.

GPU Benchmark: A100-80GB , CUDA12.2, Driver Version: 535.54.03 With BF16 Autocast: n_iterations: 20 Total latency (ms): 2248.983144760132 Average latency (ms): 112.44915723800659

cfgfung avatar Mar 25 '24 06:03 cfgfung

@cfgfung Your code looks good. Can you just modify your test file name to something like test_image_segementation.py . Also, please make sure your test runs on CI test. https://github.com/huggingface/optimum-habana/blob/8786b7592c58d394f9460710415de3c08775b1b6/Makefile#L45

jiminha avatar Apr 18 '24 19:04 jiminha

@cfgfung Your code looks good. Can you just modify your test file name to something like test_image_segementation.py . Also, please make sure your test runs on CI test.

https://github.com/huggingface/optimum-habana/blob/8786b7592c58d394f9460710415de3c08775b1b6/Makefile#L45

Thanks for the review. I have renamed the test file and add few lines of codes to the makefile for the CI tests.

cfgfung avatar Apr 22 '24 18:04 cfgfung

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? tests/test_image_segmentation.py::GaudiSAMTester::test_inference_default PASSED tests/test_image_segmentation.py::GaudiSAMTester::test_inference_hpu_graphs PASSED tests/test_image_segmentation.py::GaudiSAMTester::test_no_latency_regression_bf16 FAILED

FAILED tests/test_image_segmentation.py::GaudiSAMTester::test_no_latency_regression_bf16 - AssertionError: 81.58655166625977 not greater than or equal to 93.97604942321777

jiminha avatar Apr 23 '24 20:04 jiminha

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? tests/test_image_segmentation.py::GaudiSAMTester::test_inference_default PASSED tests/test_image_segmentation.py::GaudiSAMTester::test_inference_hpu_graphs PASSED tests/test_image_segmentation.py::GaudiSAMTester::test_no_latency_regression_bf16 FAILED

FAILED tests/test_image_segmentation.py::GaudiSAMTester::test_no_latency_regression_bf16 - AssertionError: 81.58655166625977 not greater than or equal to 93.97604942321777

Removed the file. Somehow it passed on my side. I fixed the logic of that test. It should be able to pass now.

cfgfung avatar Apr 30 '24 23:04 cfgfung

@cfgfung can you merge your change to the latest baseline?

jiminha avatar May 21 '24 23:05 jiminha

@cfgfung can you merge your change to the latest baseline?

Hi, I have applied a git rebase. It should be aligned with the latest baseline.

cfgfung avatar May 29 '24 21:05 cfgfung

@cfgfung can you rebase and provide the test result on latest?

libinta avatar Jun 25 '24 01:06 libinta

@cfgfung can you rebase and provide the test result on latest?

Hi,

I have applied rebase and ran the tests.

image

cfgfung avatar Jun 25 '24 18:06 cfgfung

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.