Skip to content

Use regexp for gpu_spec model matching, supporting both positive and exclusion patterns#677

Merged
EdwardKaravakis merged 5 commits intomasterfrom
gpu-model-exclusion-wildcard
Mar 16, 2026
Merged

Use regexp for gpu_spec model matching, supporting both positive and exclusion patterns#677
EdwardKaravakis merged 5 commits intomasterfrom
gpu-model-exclusion-wildcard

Conversation

@EdwardKaravakis
Copy link
Copy Markdown
Member

Summary

Change

# Before
if "model" in architecture_map["gpu"] and excluded_model in architecture_map["gpu"]["model"]:
    continue

# After
if "model" in architecture_map["gpu"] and any(fnmatch.fnmatch(m, excluded_model) for m in architecture_map["gpu"]["model"]):
    continue

Allow tasks to exclude a specific GPU model using != in the gpu_spec
model field of the JSON architecture string (e.g. !=Tesla P100-SXM2-16GB).
Previously only positive model matching was supported from the task side.
@EdwardKaravakis EdwardKaravakis requested a review from tmaeno March 12, 2026 13:50
@EdwardKaravakis
Copy link
Copy Markdown
Member Author

One more review @tmaeno to implement Johannes's wildcard use as in "!=P100"

@tmaeno
Copy link
Copy Markdown
Contributor

tmaeno commented Mar 12, 2026

How about allowing regexp to specify the model? You wouldn't need separate code paths
for matching and excluding patterns. For "!=P100”, it would be "^(?!.P100).$”.

@EdwardKaravakis
Copy link
Copy Markdown
Member Author

Much cleaner with your suggestion, working on it - thank you!

@EdwardKaravakis
Copy link
Copy Markdown
Member Author

@tmaeno please have a look at this new implementation based on your suggestion

@EdwardKaravakis EdwardKaravakis changed the title Support wildcards in gpu_spec model != exclusion Use regexp for gpu_spec model matching, supporting both positive and exclusion patterns Mar 12, 2026
Copy link
Copy Markdown
Contributor

@tmaeno tmaeno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I started thinking we need to introduce a separate entry in the gpu_spec for exclusion. The current code does not exclude the PQ when an item in the list passes the antimatch pattern. One possibility would be to add "excl": True, and then the logic could be something like

is_match = any(re.match(host_gpu_spec["model"], m) for m in architecture_map["gpu"]["model"])
if is_match == host_gpu_spec.get("excl", False):
    continue

{"model": "^.*P100.*", "excl": true} will exclude PQs with P100, while {"model": "^(?!.*P100).*$"} will include PQs if some model names don't contain P100.

@EdwardKaravakis
Copy link
Copy Markdown
Member Author

EdwardKaravakis commented Mar 12, 2026 via email

@EdwardKaravakis EdwardKaravakis merged commit cc56c60 into master Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants