Skip to content
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

pull code #71

Merged
merged 2 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion examples/nas/darts/retrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def validate(config, valid_loader, model, criterion, epoch, cur_step):
dataset_train, dataset_valid = datasets.get_dataset("cifar10", cutout_length=16)

model = CNN(32, 3, 36, 10, args.layers, auxiliary=True)
apply_fixed_architecture(model, args.arc_checkpoint, device=device)
apply_fixed_architecture(model, args.arc_checkpoint)
criterion = nn.CrossEntropyLoss()

model.to(device)
Expand Down
2 changes: 1 addition & 1 deletion examples/nas/enas/micro.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def forward(self, pprev, prev):
nodes_used_mask = torch.zeros(self.num_nodes + 2, dtype=torch.bool, device=prev.device)
for i in range(self.num_nodes):
node_out, mask = self.nodes[i](prev_nodes_out)
nodes_used_mask[:mask.size(0)] |= mask
nodes_used_mask[:mask.size(0)] |= mask.to(node_out.device)
prev_nodes_out.append(node_out)

unused_nodes = torch.cat([out for used, out in zip(nodes_used_mask, prev_nodes_out) if not used], 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/nas/proxylessnas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@
from nni.nas.pytorch.fixed import apply_fixed_architecture
assert os.path.isfile(args.exported_arch_path), \
"exported_arch_path {} should be a file.".format(args.exported_arch_path)
apply_fixed_architecture(model, args.exported_arch_path, device=device)
apply_fixed_architecture(model, args.exported_arch_path)
trainer = Retrain(model, optimizer, device, data_provider, n_epochs=300)
trainer.run()
17 changes: 17 additions & 0 deletions src/nni_manager/config/kubeflow/pytorchjob-crd-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"kind": "CustomResourceDefinition",
"spec": {
"scope": "Namespaced",
"version": "v1",
"group": "kubeflow.org",
"names": {
"kind": "PyTorchJob",
"plural": "pytorchjobs",
"singular": "pytorchjob"
}
},
"apiVersion": "kubeflow.org/v1",
"metadata": {
"name": "pytorchjobs.kubeflow.org"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,24 @@ class TFOperatorClientV1 extends KubernetesCRDClient {
return 'tensorflow';
}
}
class PyTorchOperatorClientV1 extends KubernetesCRDClient {
/**
* constructor, to initialize tfjob CRD definition
*/
public constructor() {
super();
this.crdSchema = JSON.parse(fs.readFileSync('./config/kubeflow/pytorchjob-crd-v1.json', 'utf8'));
this.client.addCustomResourceDefinition(this.crdSchema);
}

protected get operator(): any {
return this.client.apis['kubeflow.org'].v1.namespaces('default').pytorchjobs;
}

public get containerName(): string {
return 'pytorch';
}
}
class PyTorchOperatorClientV1Alpha2 extends KubernetesCRDClient {
/**
* constructor, to initialize tfjob CRD definition
Expand Down Expand Up @@ -179,6 +196,9 @@ class KubeflowOperatorClientFactory {
case 'v1beta2': {
return new PyTorchOperatorClientV1Beta2();
}
case 'v1': {
return new PyTorchOperatorClientV1();
}
default:
throw new Error(`Invalid pytorch-operator apiVersion ${operatorApiVersion}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AzureStorage, KeyVaultConfig, KubernetesClusterConfig, KubernetesCluste
export type KubeflowOperator = 'tf-operator' | 'pytorch-operator' ;
export type DistTrainRole = 'worker' | 'ps' | 'master';
export type KubeflowJobStatus = 'Created' | 'Running' | 'Failed' | 'Succeeded';
export type OperatorApiVersion = 'v1alpha2' | 'v1beta1' | 'v1beta2';
export type OperatorApiVersion = 'v1alpha2' | 'v1beta1' | 'v1beta2' | 'v1';

/**
* Kubeflow Cluster Configuration
Expand Down