Skip to content

Conversation

@ActiveChooN
Copy link

@ActiveChooN ActiveChooN commented Nov 7, 2025

📝 Description

Screenshot 2025-11-07 at 10 03 19 Added device selector in training dialog

✨ Changes

Select what type of change your PR is:

  • 🚀 New feature (non-breaking change which adds functionality)
  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔄 Refactor (non-breaking change which refactors the code base)
  • ⚡ Performance improvements
  • 🎨 Style changes (code style/formatting)
  • 🧪 Tests (adding/modifying tests)
  • 📚 Documentation update
  • 📦 Build system changes
  • 🚧 CI/CD configuration
  • 🔧 Chore (general maintenance)
  • 🔒 Security update
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).
  • 🏷️ My PR title follows conventional commit format.

For more information about code review checklists, see the Code Review Checklist.

Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings November 7, 2025 09:07
Copy link
Contributor

Copilot AI left a 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.

@ActiveChooN ActiveChooN changed the title Device selection in training model dialog feat(inspect): Device selection in training model dialog Nov 7, 2025
@ActiveChooN ActiveChooN marked this pull request as ready for review November 7, 2025 12:03
Copilot AI review requested due to automatic review settings November 7, 2025 12:03
Copy link
Contributor

Copilot AI left a 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.

ActiveChooN and others added 3 commits November 7, 2025 13:05
…vice-picker.component.tsx

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Dmitry Kalinin <[email protected]>
Signed-off-by: Dmitry Kalinin <[email protected]>
@ActiveChooN ActiveChooN force-pushed the feature/training-device-selector branch from 5f2c043 to e5704f8 Compare November 7, 2025 12:05
isRefetching,
refetch,
} = $api.useQuery('get', '/api/training-devices');
const devices = useMemo(() => availableDevices?.devices ?? [], [availableDevices]);

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.

Copy link
Author

@ActiveChooN ActiveChooN Nov 7, 2025

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

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.

Comment on lines +42 to +45
const [selectedDevice, setSelectedDevice] = useState<string | null>(null);
const handleDeviceSelect = useCallback((device: string | null) => {
setSelectedDevice(device);
}, []);

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)

Suggested change
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);

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:

  1. XPU
  2. GPU
  3. MPS
  4. CPU

isRefetching,
refetch,
} = $api.useQuery('get', '/api/training-devices');
const devices = useMemo(() => availableDevices?.devices ?? [], [availableDevices]);

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');

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(() => {

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(() => {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants