Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Add recently-idle environment scheduler in reuse mode #3375

Merged
merged 150 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 149 commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
dcd2ffd
Merge pull request #251 from microsoft/master
SparkSnail May 29, 2020
a738331
init changes
squirrelsc Jun 2, 2020
3177aeb
Merge remote-tracking branch 'official/master' into 2391-reuse-job
squirrelsc Jun 2, 2020
2aafac1
refactors
squirrelsc Jun 3, 2020
0435b7f
refactoring
squirrelsc Jun 3, 2020
2e5ef51
minor fix, and take some review comments.
squirrelsc Jun 3, 2020
6d7bc62
move reuse to upper level
squirrelsc Jun 3, 2020
c67b162
support multi nodes
Jun 4, 2020
e13a620
fix eslint errors
Jun 4, 2020
59d4a71
support multi environments better
Jun 5, 2020
eae0540
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 5, 2020
81c49cf
code refactor
Jun 5, 2020
92cab3a
fix openpai yaml format
Jun 5, 2020
0674d88
fix k8s yaml schema
Jun 5, 2020
e5b9665
rename forward training service
Jun 5, 2020
67ef648
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 5, 2020
3b8b6fb
Merge pull request #252 from microsoft/master
SparkSnail Jun 7, 2020
1e626fd
add trialService
Jun 9, 2020
c6b6061
not send stop for single node
Jun 9, 2020
916e444
Merge pull request #253 from microsoft/master
SparkSnail Jun 15, 2020
b8e47be
rename environmentManager to trialDispatcher
Jun 16, 2020
0ee933a
support no central storage service
Jun 16, 2020
c7973be
init
SparkSnail Jun 16, 2020
c094057
improve delopment support
Jun 16, 2020
c2735d3
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 16, 2020
d0b2504
use latest storage component
Jun 16, 2020
c8d4696
add gpu info
Jun 16, 2020
1a9f19f
work version
SparkSnail Jun 16, 2020
3f4c177
separate channel and add gpu collector in runner
Jun 16, 2020
648e0bb
Merge branch '2391-reuse-job' of https://github.com/squirrelsc/nni in…
SparkSnail Jun 16, 2020
2fa4a77
init
SparkSnail Jun 16, 2020
caeffb8
Merge pull request #254 from microsoft/master
SparkSnail Jun 17, 2020
d0768b0
add more GPU information, and improve debugging.
squirrelsc Jun 17, 2020
8dff16f
fix GPU info collector
Jun 17, 2020
bea8ed6
Merge branch '2391-reuse-job' of https://github.com/squirrelsc/nni in…
SparkSnail Jun 18, 2020
e297aa5
update
SparkSnail Jun 18, 2020
500c1cb
channel support single file
Jun 18, 2020
d880512
refine code, and implement command channel
Jun 19, 2020
5c33d11
update
SparkSnail Jun 20, 2020
45424e8
support concurrent trials in runner.
Jun 22, 2020
9ca3444
implement web channel
Jun 24, 2020
5018039
fix eslint errors, and rename rest to web
Jun 24, 2020
283bceb
remove trial service, as it's replaced by channel.
Jun 24, 2020
0c67c5c
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 24, 2020
671f5d8
fix merged problem, and small refine for ut.
Jun 24, 2020
a65a810
fix pylint errors
Jun 24, 2020
6d36ae5
fix lint error
Jun 26, 2020
5e352f7
init
SparkSnail Jun 26, 2020
b9d1aa5
fix conflict
SparkSnail Jun 28, 2020
a3a91d8
format
SparkSnail Jun 28, 2020
57c300e
Merge pull request #255 from microsoft/master
SparkSnail Jun 28, 2020
69a5170
remove useless deferred.
Jun 29, 2020
edc4608
fix package
SparkSnail Jun 29, 2020
c1f0239
fix incorrect check logic
Jun 29, 2020
af97bb1
make license header consistent
Jun 29, 2020
10feb6a
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 29, 2020
c00cd31
add missed await.
Jun 29, 2020
78f1386
add doc and example
SparkSnail Jun 29, 2020
586d6ac
support log level in UT
Jun 29, 2020
2db8ff8
refine interface to support aml better.
Jun 29, 2020
f631e4c
fix runtime error on exit
Jun 29, 2020
5982fb3
Merge remote-tracking branch 'official/master' into 2391-reuse-job
Jun 29, 2020
f687a6e
fix eslint error
Jun 29, 2020
476ffec
send metric data from channel
Jun 29, 2020
0f2367c
support version check
Jun 29, 2020
9d7bd3c
fix pylint errors
Jun 29, 2020
130ed27
fix non-local failed ITs
Jun 29, 2020
ab86080
fix comments
SparkSnail Jun 30, 2020
4b11a53
fix conflict
SparkSnail Jun 30, 2020
15ee064
fix conflict
SparkSnail Jun 30, 2020
7c48610
format
SparkSnail Jun 30, 2020
c0c7d96
format code
SparkSnail Jun 30, 2020
93eefb2
format code
SparkSnail Jun 30, 2020
53cea0f
remove unused code
SparkSnail Jun 30, 2020
34d9351
format code
SparkSnail Jun 30, 2020
25a9dab
fix comments
SparkSnail Jun 30, 2020
cada76a
fix comments
SparkSnail Jun 30, 2020
de7dc7c
fix comments
SparkSnail Jun 30, 2020
428dc3d
add blank line
SparkSnail Jun 30, 2020
2e9c70e
fix comments
SparkSnail Jun 30, 2020
8cf8583
fix comments
SparkSnail Jun 30, 2020
fd5fd9e
fix build
SparkSnail Jun 30, 2020
54a22af
fix comments
SparkSnail Jun 30, 2020
525b961
fix channel async calls
Jun 30, 2020
8ec5e7d
fix comments
SparkSnail Jun 30, 2020
bdd3840
fix comments
SparkSnail Jun 30, 2020
b341dce
fix comments
SparkSnail Jun 30, 2020
ce81c51
Merge remote-tracking branch 'snail/dev-aml' into 2391-improve
Jun 30, 2020
e66dc23
fix comments
SparkSnail Jun 30, 2020
9cf6744
merge code logic
Jun 30, 2020
bd77f5c
Merge remote-tracking branch 'snail/dev-aml' into 2391-improve
Jun 30, 2020
ddfb0cc
Merge branch 'master' of https://github.com/microsoft/nni into dev-aml
SparkSnail Jun 30, 2020
65660e6
Merge pull request #257 from microsoft/master
SparkSnail Jun 30, 2020
fec8a67
Merge branch 'master' of https://github.com/SparkSnail/nni into dev-aml
SparkSnail Jun 30, 2020
5200a3a
Merge remote-tracking branch 'snail/dev-aml' into 2391-improve
Jun 30, 2020
51befa5
fix eslint errors
Jun 30, 2020
478629f
add run fo messages
Jun 30, 2020
c299ce1
Merge pull request #256 from squirrelsc/2391-improve
SparkSnail Jun 30, 2020
0517e13
fix comments
SparkSnail Jun 30, 2020
fc4b978
sort class
SparkSnail Jun 30, 2020
e527743
fix eslint
SparkSnail Jun 30, 2020
b047681
fix eslint
SparkSnail Jun 30, 2020
4acc7e8
fix annotation
SparkSnail Jun 30, 2020
ec1475a
fix import aml
SparkSnail Jun 30, 2020
8eaeebf
fix comments
SparkSnail Jun 30, 2020
56b6818
fix doc build
SparkSnail Jul 1, 2020
e09ff79
fix trial_runner import
SparkSnail Jul 1, 2020
ecf615d
fix doc
SparkSnail Jul 1, 2020
a7a3baf
fix pylint
SparkSnail Jul 1, 2020
9376d6a
Merge pull request #258 from microsoft/master
SparkSnail Jul 1, 2020
870f1e6
Merge branch 'master' of https://github.com/SparkSnail/nni into dev-aml
SparkSnail Jul 1, 2020
7eaa105
add doc for aml
SparkSnail Jul 1, 2020
a0ea554
add content
SparkSnail Jul 1, 2020
972822c
supplement dlts doc
SparkSnail Jul 1, 2020
b5f7f06
add doc content
SparkSnail Jul 1, 2020
f6d9c3f
fix content
SparkSnail Jul 1, 2020
f39036f
fix content
SparkSnail Jul 1, 2020
5e366cf
fix broken link
SparkSnail Jul 1, 2020
43b12b6
Merge branch 'v1.7' into dev-aml
squirrelsc Jul 3, 2020
5fef3cf
Merge pull request #259 from microsoft/master
SparkSnail Jul 3, 2020
9a864fd
Merge branch 'master' of https://github.com/SparkSnail/nni into dev-aml
SparkSnail Jul 3, 2020
3515185
Merge branch 'dev-aml' of https://github.com/SparkSnail/nni into dev-aml
SparkSnail Jul 3, 2020
b3ec35a
fix aml docker image
SparkSnail Jul 3, 2020
5544ae8
Merge pull request #261 from microsoft/master
SparkSnail Jul 10, 2020
f9fdfee
Merge pull request #262 from microsoft/master
SparkSnail Jul 16, 2020
e6c11b1
Merge branch 'master' of https://github.com/SparkSnail/nni into dev-aml
SparkSnail Jul 23, 2020
5e4c09d
fix aml error information
SparkSnail Jul 23, 2020
7242add
add annotation
SparkSnail Jul 23, 2020
aa64fe6
Merge pull request #263 from microsoft/master
SparkSnail Jul 27, 2020
c6a5f8c
Merge pull request #264 from microsoft/master
SparkSnail Jul 31, 2020
68abe2f
Merge pull request #265 from microsoft/master
SparkSnail Aug 4, 2020
14e9619
Merge pull request #266 from microsoft/master
SparkSnail Aug 13, 2020
f69e206
Merge pull request #267 from microsoft/master
SparkSnail Aug 13, 2020
12ef0aa
Merge pull request #270 from microsoft/master
SparkSnail Sep 10, 2020
ddcf229
Merge pull request #271 from microsoft/master
SparkSnail Sep 15, 2020
c4f6e66
Merge pull request #272 from microsoft/master
SparkSnail Sep 21, 2020
88f8c1b
Merge pull request #273 from microsoft/master
SparkSnail Sep 22, 2020
7eb15f8
Merge pull request #274 from microsoft/master
SparkSnail Oct 27, 2020
f73367f
Merge pull request #275 from microsoft/master
SparkSnail Nov 16, 2020
765bc33
Merge pull request #276 from microsoft/master
SparkSnail Nov 29, 2020
cff51cc
Merge pull request #277 from microsoft/master
SparkSnail Dec 2, 2020
4232fea
Merge pull request #278 from microsoft/master
SparkSnail Dec 8, 2020
cb9efcc
Merge pull request #279 from microsoft/master
SparkSnail Dec 11, 2020
ee71f16
Merge pull request #280 from microsoft/master
SparkSnail Dec 14, 2020
c3921ed
Merge pull request #281 from microsoft/master
SparkSnail Dec 24, 2020
561f1ad
Merge pull request #284 from microsoft/master
SparkSnail Jan 22, 2021
daf028a
Merge pull request #285 from microsoft/master
SparkSnail Feb 5, 2021
0d41f82
fix conflict
SparkSnail Feb 5, 2021
f2c2f8b
init
SparkSnail Feb 8, 2021
2706cb1
fix eslint
SparkSnail Feb 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ts/nni_manager/training_service/reusable/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class EnvironmentInformation {
// uses to count how many trial runs on this environment.
// it can be used in many scenarios, but for now, it uses for reusable.
public assignedTrialCount: number = 0;
// it is used to get environment idle time interval
public latestTrialReleasedTime: number = -1;

// NNI environment ID
public id: string;
Expand Down
25 changes: 23 additions & 2 deletions ts/nni_manager/training_service/reusable/gpuScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { GPUInfo, ScheduleResultType } from '../common/gpuData';
import { EnvironmentInformation } from './environment';
import { TrialDetail } from './trial';

type SCHEDULE_POLICY_NAME = 'random' | 'round-robin';
type SCHEDULE_POLICY_NAME = 'random' | 'round-robin' | 'recently-idle';

export class GpuSchedulerSetting {
public useActiveGpu: boolean = false;
Expand All @@ -30,7 +30,7 @@ export class GpuScheduler {

// private readonly machineExecutorMap: Set<TrialDetail>;
private readonly log: Logger = getLogger();
private readonly policyName: SCHEDULE_POLICY_NAME = 'round-robin';
private readonly policyName: SCHEDULE_POLICY_NAME = 'recently-idle';
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible that only apply this policy for aml training service?

private defaultSetting: GpuSchedulerSetting;
private roundRobinIndex: number = 0;

Expand Down Expand Up @@ -101,6 +101,7 @@ export class GpuScheduler {
trial.environment.defaultGpuSummary !== undefined &&
trial.assignedGpus !== undefined &&
trial.assignedGpus.length > 0) {

for (const gpuInfo of trial.assignedGpus) {
const defaultGpuSummary = trial.environment.defaultGpuSummary;
const num: number | undefined = defaultGpuSummary.assignedGpuIndexMap.get(gpuInfo.index);
Expand Down Expand Up @@ -190,10 +191,30 @@ export class GpuScheduler {
return randomSelect(qualifiedEnvironments);
} else if (this.policyName === 'round-robin') {
return this.roundRobinSelect(qualifiedEnvironments, allEnvironments);
} else if (this.policyName === 'recently-idle') {
return this.recentlyIdleSelect(qualifiedEnvironments, allEnvironments);
} else {
throw new Error(`Unsupported schedule policy: ${this.policyName}`);
}
}

// Select the environment which is idle most recently. If all environments are not idle, use round robin to select an environment.
private recentlyIdleSelect(qualifiedEnvironments: EnvironmentInformation[], allEnvironments: EnvironmentInformation[]) : EnvironmentInformation {
const now = Date.now();
let selectedEnvironment: EnvironmentInformation | undefined = undefined;
let minTimeInterval = Number.MAX_SAFE_INTEGER;
for (let environment of qualifiedEnvironments) {
if (environment.latestTrialReleasedTime > 0 && (now - environment.latestTrialReleasedTime) < minTimeInterval) {
selectedEnvironment = environment;
minTimeInterval = now - environment.latestTrialReleasedTime;
}
}
if (selectedEnvironment === undefined) {
return this.roundRobinSelect(qualifiedEnvironments, allEnvironments);
}
selectedEnvironment.latestTrialReleasedTime = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, one environment only runs one trial at a time?

Copy link
Contributor

Choose a reason for hiding this comment

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

if it is, then policy looks good. if not, one environment can run two trials concurrently, then this policy becomes round robin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could run multiple trial at one environment, why it will become round-robin?

return selectedEnvironment;
}

private roundRobinSelect(qualifiedEnvironments: EnvironmentInformation[], allEnvironments: EnvironmentInformation[]): EnvironmentInformation {
while (!qualifiedEnvironments.includes(allEnvironments[this.roundRobinIndex % allEnvironments.length])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ class TrialDispatcher implements TrainingService {
throw new Error(`TrialDispatcher: environment ${trial.environment.id} has no counted running trial!`);
}
trial.environment.runningTrialCount--;
trial.environment.latestTrialReleasedTime = Date.now();
trial.environment = undefined;
}
if (true === this.enableGpuScheduler) {
Expand Down