-
Notifications
You must be signed in to change notification settings - Fork 836
feat(inspect): Device selection in training model dialog #3094
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
base: feature/geti-inspect
Are you sure you want to change the base?
feat(inspect): Device selection in training model dialog #3094
Conversation
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.
Pull Request Overview
This PR adds device selection functionality to the training model dialog, allowing users to choose which hardware device (CPU, GPU, TPU, etc.) should be used for model training.
Key Changes:
- Added a new device picker component that displays available training devices with descriptions
- Integrated device selection into the training workflow, making it a required field before starting training
- Created device metadata utilities to provide user-friendly labels and descriptions for different hardware accelerators
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| application/ui/tsconfig.json | Removed trailing comma from JSON configuration |
| application/ui/tests/tsconfig.json | Removed trailing comma from JSON configuration |
| application/ui/src/features/inspect/train-model/utils/device-metadata.ts | New utility file providing metadata (labels and descriptions) for various device types |
| application/ui/src/features/inspect/train-model/train-model.module.scss | Added styling for device selection UI components |
| application/ui/src/features/inspect/train-model/train-model-dialog.component.tsx | Integrated device picker into dialog and updated training logic to use selected device |
| application/ui/src/features/inspect/train-model/train-model-device-picker.component.tsx | New component for device selection with loading, error, and empty states |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
application/ui/src/features/inspect/train-model/train-model-device-picker.component.tsx
Outdated
Show resolved
Hide resolved
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.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
application/ui/src/features/inspect/train-model/train-model-device-picker.component.tsx
Show resolved
Hide resolved
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Dmitry Kalinin <[email protected]>
…vice-picker.component.tsx Co-authored-by: Copilot <[email protected]> Signed-off-by: Dmitry Kalinin <[email protected]>
Signed-off-by: Dmitry Kalinin <[email protected]>
5f2c043 to
e5704f8
Compare
| isRefetching, | ||
| refetch, | ||
| } = $api.useQuery('get', '/api/training-devices'); | ||
| const devices = useMemo(() => availableDevices?.devices ?? [], [availableDevices]); |
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.
I was under the impression that we wouldn’t need useMemo and useCallback anymore.
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.
Did we enable react compiler in the app? I can't find it in the rsbuild conf
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.
I think it's not enabled yet, but in this case the memo won't really be useful imoh since the query data should be stable.
| const [selectedDevice, setSelectedDevice] = useState<string | null>(null); | ||
| const handleDeviceSelect = useCallback((device: string | null) => { | ||
| setSelectedDevice(device); | ||
| }, []); |
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.
imho adding the extra handleDeviceSelect is not necessary (either rename it here, or use the old name below)
| const [selectedDevice, setSelectedDevice] = useState<string | null>(null); | |
| const handleDeviceSelect = useCallback((device: string | null) => { | |
| setSelectedDevice(device); | |
| }, []); | |
| const [selectedDevice, handleDeviceSelect] = useState<string | null>(null); |
| setSearchParams(searchParams); | ||
| }; | ||
| const [selectedModel, setSelectedModel] = useState<string | null>(null); | ||
| const [selectedDevice, setSelectedDevice] = useState<string | null>(null); |
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.
I think it would be good to select a device by default. Ideally we should prioritize:
- XPU
- GPU
- MPS
- CPU
| isRefetching, | ||
| refetch, | ||
| } = $api.useQuery('get', '/api/training-devices'); | ||
| const devices = useMemo(() => availableDevices?.devices ?? [], [availableDevices]); |
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.
I think it's not enabled yet, but in this case the memo won't really be useful imoh since the query data should be stable.
| isError, | ||
| isRefetching, | ||
| refetch, | ||
| } = $api.useQuery('get', '/api/training-devices'); |
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.
You could use useSuspenseQuery here and avoid having to do all the loading checks.
| const hasDevices = devices.length > 0; | ||
| const isLoadingDevices = isLoading || isRefetching; | ||
|
|
||
| useEffect(() => { |
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.
I think we could avoid this useEffect by moving the query (using suspense query) to the location where we define the useState for the selected device, and then use the query's data to select the default device.
Something like this,
const {
data: availableDevices = [],
} = $api.useQuery('get', '/api/training-devices');
const [selectedDevice, setSelectedDevice] = useState<string | null>(availableDevices.at(0) ?? null);| } | ||
| }, [devices, hasDevices, isError, isLoadingDevices, onSelect, selectedDevice]); | ||
|
|
||
| const deviceOptions = useMemo(() => { |
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.
I think we can skip this useMemo since this component would be rerendering anyway when the useMemo is called.
📝 Description
Closes 📋 [TASK] Training device selector #3096
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.