|
16 | 16 | from examples.models import MODEL_NAME_TO_MODEL
|
17 | 17 |
|
18 | 18 |
|
19 |
| -# Device pools for AWS Device Farm |
| 19 | +DEVICE_POOLS_REGEX = re.compile(r"(?P<device_name>[^\+]+)\+(?P<variant>[^\+]+)") |
| 20 | +# Device pools for AWS Device Farm. Initially, I choose to distribute models to these pool |
| 21 | +# round-robin for simplicity. For public pool, only one per device type is needed because |
| 22 | +# AWS will scale the number of devices there for us. However, for private pool, we need to |
| 23 | +# manually maintain multiple pools of the same device to evenly distribute models there. |
| 24 | +# The pool ARNs are extracted from the output of the following command: |
| 25 | +# aws devicefarm list-device-pools \ |
| 26 | +# --arn arn:aws:devicefarm:us-west-2:308535385114:project:02a2cf0f-6d9b-45ee-ba1a-a086587469e6 \ |
| 27 | +# --region us-west-2 |
20 | 28 | DEVICE_POOLS = {
|
21 |
| - "apple_iphone_15": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/3b5acd2e-92e2-4778-b651-7726bafe129d", |
22 |
| - "apple_iphone_15+ios_18": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/12c8b15c-8d03-4e07-950d-0a627e7595b4", |
23 |
| - "samsung_galaxy_s22": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/e59f866a-30aa-4aa1-87b7-4510e5820dfa", |
24 |
| - "samsung_galaxy_s22_private": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/ea6b049d-1508-4233-9a56-5d9eacbe1078", |
25 |
| - "samsung_galaxy_s24": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98f8788c-2e25-4a3c-8bb2-0d1e8897c0db", |
26 |
| - "google_pixel_8_pro": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/d65096ab-900b-4521-be8b-a3619b69236a", |
27 |
| - "google_pixel_3_private_rooted": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98d23ca8-ea9e-4fb7-b725-d402017b198d", |
28 |
| - "apple_iphone_15_private": "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/55929353-2f28-4ee5-bdff-d1a95f58cb28", |
| 29 | + "apple_iphone_15": { |
| 30 | + "public": [ |
| 31 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/3b5acd2e-92e2-4778-b651-7726bafe129d", |
| 32 | + ], |
| 33 | + "ios_18_public": [ |
| 34 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/12c8b15c-8d03-4e07-950d-0a627e7595b4", |
| 35 | + ], |
| 36 | + "private": [ |
| 37 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/55929353-2f28-4ee5-bdff-d1a95f58cb28", |
| 38 | + ], |
| 39 | + "plus_private": [ |
| 40 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/767bfb3e-a00e-4d92-998b-4eafdcf7213b", |
| 41 | + ], |
| 42 | + "pro_private": [ |
| 43 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/1394f34c-2981-4c55-aaa2-246871ac713b", |
| 44 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/099e8def-4609-4383-8787-76b88e500c1d", |
| 45 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/d6707270-b009-479e-a83a-7bdb255f9de5", |
| 46 | + ], |
| 47 | + }, |
| 48 | + "samsung_galaxy_s22": { |
| 49 | + "public": [ |
| 50 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/e59f866a-30aa-4aa1-87b7-4510e5820dfa", |
| 51 | + ], |
| 52 | + "private": [ |
| 53 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/ea6b049d-1508-4233-9a56-5d9eacbe1078", |
| 54 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/1fa924a1-5aff-475b-8f4d-f7c6d8de4fe9", |
| 55 | + ], |
| 56 | + "ultra_private": [ |
| 57 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/5f79d72e-e229-4f9c-962f-5d37196fcfe7", |
| 58 | + ], |
| 59 | + }, |
| 60 | + "samsung_galaxy_s24": { |
| 61 | + "public": [ |
| 62 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98f8788c-2e25-4a3c-8bb2-0d1e8897c0db", |
| 63 | + ], |
| 64 | + "ultra_private": [ |
| 65 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/5f79d72e-e229-4f9c-962f-5d37196fcfe7", |
| 66 | + ], |
| 67 | + }, |
| 68 | + "google_pixel_8": { |
| 69 | + "pro_public": [ |
| 70 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/d65096ab-900b-4521-be8b-a3619b69236a", |
| 71 | + ], |
| 72 | + }, |
| 73 | + "google_pixel_3": { |
| 74 | + "rooted_private": [ |
| 75 | + "arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/98d23ca8-ea9e-4fb7-b725-d402017b198d", |
| 76 | + ], |
| 77 | + }, |
29 | 78 | }
|
30 | 79 |
|
31 | 80 | # Predefined benchmark configurations
|
@@ -318,25 +367,56 @@ def get_benchmark_configs() -> Dict[str, Dict]: # noqa: C901
|
318 | 367 |
|
319 | 368 | # Add configurations for each valid device
|
320 | 369 | for device in devices:
|
| 370 | + # Parse the device name |
| 371 | + m = re.match(DEVICE_POOLS_REGEX, device) |
| 372 | + if not m: |
| 373 | + logging.warning( |
| 374 | + f"Invalid device name: {device} is not in DEVICE_NAME+VARIANT format. Skipping." |
| 375 | + ) |
| 376 | + continue |
| 377 | + |
| 378 | + device_name = m.group("device_name") |
| 379 | + variant = m.group("variant") |
| 380 | + |
| 381 | + if device_name not in DEVICE_POOLS: |
| 382 | + logging.warning(f"Unsupported device '{device}'. Skipping.") |
| 383 | + continue |
| 384 | + |
| 385 | + if variant not in DEVICE_POOLS[device_name]: |
| 386 | + logging.warning( |
| 387 | + f"Unsupported {device}'s variant '{variant}'. Skipping." |
| 388 | + ) |
| 389 | + continue |
| 390 | + |
| 391 | + device_pool_count = len(DEVICE_POOLS[device_name][variant]) |
| 392 | + if not device_pool_count: |
| 393 | + logging.warning( |
| 394 | + f"No device pool defined for {device}'s variant '{variant}'. Skipping." |
| 395 | + ) |
| 396 | + continue |
| 397 | + |
| 398 | + device_pool_index = 0 |
321 | 399 | for config in configs:
|
322 |
| - if config == "llama3_coreml_ane" and not device.endswith("+ios_18"): |
323 |
| - device = f"{device}+ios_18" |
| 400 | + if config == "llama3_coreml_ane" and "ios_18" not in variant: |
| 401 | + variant = "ios_18_public" |
324 | 402 | logging.info(
|
325 |
| - f"Benchmark config '{config}' only works on iOS 18+, auto-upgraded device pool to '{device}'" |
| 403 | + f"Benchmark config '{config}' only works on iOS 18+, auto-upgraded device variant to '{variant}'" |
326 | 404 | )
|
327 | 405 |
|
328 |
| - if device not in DEVICE_POOLS: |
329 |
| - logging.warning(f"Unsupported device '{device}'. Skipping.") |
330 |
| - continue |
331 |
| - |
332 | 406 | record = {
|
333 | 407 | "model": model_name,
|
334 | 408 | "config": config,
|
335 |
| - "device_name": device, |
336 |
| - "device_arn": DEVICE_POOLS[device], |
| 409 | + "device_name": device_name, |
| 410 | + "variant": variant, |
| 411 | + "device_arn": DEVICE_POOLS[device_name][variant][ |
| 412 | + device_pool_index % device_pool_count |
| 413 | + ], |
337 | 414 | }
|
338 | 415 | benchmark_configs["include"].append(record)
|
339 | 416 |
|
| 417 | + # Distribute configs to pools of the same device round-robin |
| 418 | + device_pool_index += 1 |
| 419 | + |
340 | 420 | set_output("benchmark_configs", json.dumps(benchmark_configs))
|
341 | 421 |
|
342 | 422 |
|
|
0 commit comments