def dump_state(self, step: int) -> None:
"""Dumps the state of the model to a file."""
if self.is_coordinator:
state = self.optimizer.state_dict()
with open(self.get_checkpoint_path(step), "w") as f:
f.write(flax.serialization.to_state_dict(state))
def dump_state(self, ckpt_path: str):
with open(ckpt_path, "wb") as f:
f.write(
flax.serialization.msgpack_serialize(
jax.device_get(flax.jax_utils.unreplicate(self.state))
)
)
def dump_state(self):
"""Save the state of the model."""
if self.rank == 0:
# We only save the state of the first process.
state = {
"model": self.model.state_dict(),
"optimizer": self.optimizer.state_dict(),
"scheduler": self.scheduler.state_dict(),
}
torch.save(state, self.checkpoint_path)
def dump_state(self):
"""
Dumps the state of the inference server to a directory.
This includes the loaded models and the tokenizers.
"""
if self.rank == 0:
if not os.path.exists(self.dump_dir):
os.makedirs(self.dump_dir)
# Dump the models
for model_name, model in self.models.items():
model.save_pretrained(os.path.join(self.dump_dir, model_name))
# Dump the tokenizers
for tokenizer_name, tokenizer in self.tokenizers.items():
tokenizer.save_pretrained(
os.path.join(self.dump_dir, tokenizer_name)
)
function Server(
notify,
config,
timer,
random,
state,
command,
answer,
action,
broadcast,
logger,
events,
dispatch,
) {
this.notify = notify;
this.config = config;
this.timer = timer;
this.random = random;
this.state = state;
this.command = command;
this.answer = answer;
this.action = action;
this.broadcast = broadcast;
this.logger = logger;
this.events = events;
this.dispatch = dispatch;
this.events.on(
"change",
function (event) {
this.state.update(event.data);
}.bind(this),
);
}
- aws_acm_certificate
- aws_acm_certificate_validation
- aws_acmpca_certificate
- aws_api_gateway_api_key
- aws_api_gateway_authorizer
- aws_api_gateway_deployment
- aws_api_gateway_integration
- aws_api_gateway_integration_response
- aws_api_gateway_method
- aws_api_gateway_method_response
- aws_api_gateway_method_settings
- aws_api_gateway_model
- aws_api_gateway_resource
- aws_api_gateway_rest_api
- aws_api_gateway_stage
- aws_api_gateway_usage_plan
- aws_api_gateway_usage_plan_key
- aws_api_gateway_vpc_link
- aws_appautoscaling_policy
- aws_appautoscaling_target
- aws_appsync_api_key
- aws_appsync_datasource
- aws_appsync_function
- aws_appsync_graphql_api
- aws_appsync_resolver
- aws_athena_database
- aws_athena_named_query
- aws_autoscaling_group
- aws_autoscaling_lifecycle_hook
- aws_autoscaling_notification
- aws_autoscaling_policy
- aws_autoscaling_schedule
- aws_backup_plan
- aws_backup_selection
- aws_backup_vault
- aws_batch_compute_environment
- aws_batch_job_definition
- aws_batch_job_queue
- aws_cloudformation_stack
- aws_cloudformation_stack_set
- aws_cloudformation_stack_set_instance
- aws_cloudfront_distribution
- aws_cloudfront_origin_access_identity
- aws_cloudfront_public_key
- aws_cloudhsm_v2_cluster
- aws_cloudhsm_v2_hsm
- aws_cloudtrail
- aws_cloudwatch_dashboard
- aws_cloudwatch_event_permission
- aws_cloudwatch_event_rule
- aws_cloudwatch_event_target
- aws_cloudwatch_log_destination
- aws_cloudwatch_log_destination_policy
- aws_cloudwatch_log_group
- aws_cloudwatch_log_metric_filter
- aws_cloudwatch_log_resource_policy
- aws_cloudwatch_log_subscription_filter
- aws_cloudwatch_metric_alarm
- aws_codebuild_project
- aws_codecommit_repository
- aws_codedeploy_app
- aws_codedeploy_deployment_config
- aws_codedeploy_deployment_group
- aws_codepipeline
- aws_codepipeline_webhook
- aws_cognito_identity_pool
- aws_cognito_identity_pool_roles_attachment
- aws_cognito_user_group
- aws_cognito_user_pool
- aws_cognito_user_pool_client
- aws_cognito_user_pool_domain
- aws_config_config_rule
- aws_config_configuration_recorder
- aws_config_configuration_recorder_status
- aws_config_delivery_channel
- aws_cur_report_definition
- aws_datapipeline_pipeline
- aws_dax_cluster
- aws_dax_parameter_group
- aws_dax_subnet_group
- aws_devicefarm_project
- aws_directory_service_directory
- aws_dlm_lifecycle_policy
- aws_dms_certificate
- aws_dms_endpoint
- aws_dms_replication_instance
- aws_dms_replication_subnet_group
- aws_dms_replication_task
- aws_dx_connection
- aws_dx_gateway
- aws_dx_gateway_association
- aws_dx_hosted_private_virtual_interface_accepter
- aws_dx_lag
- aws_dx_private_virtual_interface
- aws_dx_public_virtual_interface
- aws_dynamodb_global_table
- aws_dynamodb_table
- aws_dynamodb_table_item
- aws_ebs_snapshot
- aws_ebs_snapshot_copy
- aws_ebs_volume
- aws_ec2_capacity_reservation
- aws_ec2_client_vpn_endpoint
- aws_ec2_client_vpn_network_association
- aws_ec2_fleet
- aws_ec2_local_gateway_route_table_vpc_association
- aws_ec2_transit_gateway
- aws_ec2_transit_gateway_route
- aws_ec2_transit_gateway_route_table
- aws_ec2_transit_gateway_route_table_association
- aws_ec2_transit_gateway_route_table_propagation
- aws_ec2_transit_gateway_vpc_attachment
- aws_ec2_transit_gateway_vpc_attachment_accepter
- aws_ecr_lifecycle_policy
- aws_ecr_repository
- aws_ecr_repository_policy
- aws_ecs_cluster
- aws_ecs_service
- aws_ecs_task_definition
- aws_efs_file_system
- aws_efs_mount_target
- aws_eip
- aws_eip_association
- aws_eks_cluster
- aws_eks_fargate_profile
- aws_eks_node_group
- aws_elastic_beanstalk_application
- aws_elastic_beanstalk_application_version
- aws_elastic_beanstalk_configuration_template
- aws_elastic_beanstalk_environment
- aws_elasticache_cluster
- aws_elasticache_parameter_group
- aws_elasticache_replication_group
- aws_elasticache_security_group
- aws_elasticache_subnet_group
- aws_elasticsearch_domain
- aws_elasticsearch_domain_policy
- aws_elb
- aws_elb_attachment
- aws_emr_cluster
- aws_emr_instance_group
- aws_emr_security_configuration
- aws_fms_admin_account
- aws_fsx_lustre_file_system
- aws_gamelift_alias
- aws_gamelift_build
- aws_gamelift_fleet
- aws_gamelift_game_session_queue
- aws_glacier_vault
- aws_glacier_vault_lock
- aws_glue_catalog_database
- aws_glue_catalog_table
- aws_glue_classifier
- aws_glue_connection
- aws_glue_crawler
- aws_glue_job
- aws_glue_security_configuration
- aws_glue_trigger
- aws_guardduty_detector
- aws_guardduty_ipset
- aws_guardduty_member
- aws_guardduty_threatintelset
- aws_iam_access_key
- aws_iam_account_alias
- aws_iam_account_password_policy
- aws_iam_group
- aws_iam_group_membership
- aws_iam_group_policy
- aws_iam_group_policy_attachment
- aws_iam_instance_profile
- aws_iam_openid_connect_provider
- aws_iam_policy
- aws_iam_policy_attachment
- aws_iam_role
- aws_iam_role_policy
- aws_iam_role_policy_attachment
- aws_iam_saml_provider
- aws_iam_server_certificate
- aws_iam_user
- aws_iam_user_group_membership
- aws_iam_user_login_profile
- aws_iam_user_policy
- aws_iam_user_policy_attachment
- aws_iam_user_ssh_key
- aws_inspector_assessment_target
- aws_inspector_assessment_template
- aws_inspector_resource_group
- aws_instance
- aws_internet_gateway
- aws_iot_certificate
- aws_iot_policy
- aws_iot_policy_attachment
- aws_iot_role_alias
- aws_iot_thing
- aws_iot_thing_principal_attachment
- aws_iot_topic_rule
- aws_key_pair
- aws_kinesis_analytics_application
- aws_kinesis_firehose_delivery_stream
- aws_kinesis_stream
- aws_kms_alias
- aws_kms_external_key
- aws_kms_grant
- aws_kms_key
- aws_lambda_alias
- aws_lambda_event_source_mapping
- aws_lambda_function
- aws_lambda_layer_version
- aws_lambda_permission
- aws_launch_configuration
- aws_launch_template
- aws_lb
- aws_lb_listener
- aws_lb_listener_certificate
- aws_lb_listener_rule
- aws_lb_target_group
- aws_lb_target_group_attachment
- aws_lightsail_domain
- aws_lightsail_instance
- aws_lightsail_key_pair
- aws_lightsail_static_ip
- aws_lightsail_static_ip_attachment
- aws_macie_member_account_association
- aws_media_convert_queue
- aws_media_package_channel
- aws_media_store_container
- aws_mq_broker
- aws_mq_configuration
- aws_msk_cluster
- aws_nat_gateway
- aws_neptune_cluster
- aws_neptune_cluster_instance
- aws_neptune_cluster_parameter_group
- aws_neptune_event_subscription
- aws_neptune_parameter_group
- aws_neptune_subnet_group
- aws_network_acl
- aws_network_acl_rule
- aws_network_interface
- aws_network_interface_attachment
- aws_opsworks_application
- aws_opsworks_custom_layer
- aws_opsworks_ganglia_layer
- aws_opsworks_haproxy_layer
- aws_opsworks_instance
- aws_opsworks_java_app_layer
- aws_opsworks_memcached_layer
- aws_opsworks_mysql_layer
- aws_opsworks_nodejs_app_layer
- aws_opsworks_permission
- aws_opsworks_php_app_layer
- aws_opsworks_rails_app_layer
- aws_opsworks_rds_db_instance
- aws_opsworks_stack
- aws_opsworks_static_web_layer
- aws_opsworks_user_profile
- aws_organizations_account
- aws_organizations_organization
- aws_organizations_policy
- aws_organizations_policy_attachment
- aws_pinpoint_adm_channel
- aws_pinpoint_apns_channel
- aws_pinpoint_apns_sandbox_channel
- aws_pinpoint_app
- aws_pinpoint_baidu_channel
- aws_pinpoint_email_channel
- aws_pinpoint_event_stream
- aws_pinpoint_gcm_channel
- aws_pinpoint_sms_channel
- aws_placement_group
- aws_qldb_ledger
- aws_quicksight_group
- aws_quicksight_user
- aws_ram_principal_association
- aws_ram_resource_share
- aws_rds_cluster
- aws_rds_cluster_endpoint
- aws_rds_cluster_instance
- aws_rds_cluster_parameter_group
- aws_rds_global_cluster
- aws_redshift_cluster
- aws_redshift_parameter_group
- aws_redshift_security_group
- aws_redshift_snapshot_copy_grant
- aws_redshift_subnet_group
- aws_resourcegroups_group
- aws_route
- aws_route53_delegation_set
- aws_route53_health_check
- aws_route53_query_log
- aws_route53_record
- aws_route53_zone
- aws_route53_zone_association
- aws_route_table
- aws_route_table_association
- aws_s3_account_public_access_block
- aws_s3_bucket
- aws_s3_bucket_inventory
- aws_s3_bucket_metric
- aws_s3_bucket_notification
- aws_s3_bucket_object
- aws_s3_bucket_policy
- aws_s3_bucket_public_access_block
- aws_sagemaker_endpoint
- aws_sagemaker_endpoint_configuration
- aws_sagemaker_model
- aws_sagemaker_notebook_instance
- aws_sagemaker_notebook_instance_lifecycle_configuration
- aws_secretsmanager_secret
- aws_secretsmanager_secret_version
- aws_security_group
- aws_security_group_rule
- aws_service_discovery_http_namespace
- aws_service_discovery_private_dns_namespace
- aws_service_discovery_public_dns_namespace
- aws_service_discovery_service
- aws_servicecatalog_portfolio
- aws_servicequotas_service_quota
- aws_ses_active_receipt_rule_set
- aws_ses_configuration_set
- aws_ses_domain_dkim
- aws_ses_domain_identity
- aws_ses_domain_identity_verification
- aws_ses_email_identity
- aws_ses_event_destination
- aws_ses_receipt_filter
- aws_ses_receipt_rule
- aws_ses_receipt_rule_set
- aws_ses_template
- aws_sfn_activity
- aws_sfn_state_machine
- aws_shield_protection
- aws_simpledb_domain
- aws_sns_platform_application
- aws_sns_sms_preferences
- aws_sns_topic
- aws_sns_topic_subscription
- aws_spot_fleet_request
- aws_spot_instance_request
- aws_sqs_queue
- aws_sqs_queue_policy
- aws_ssm_activation
- aws_ssm_association
- aws_ssm_document
- aws_ssm_maintenance_window
- aws_ssm_maintenance_window_target
- aws_ssm_maintenance_window_task
- aws_ssm_parameter
- aws_ssm_patch_baseline
- aws_ssm_patch_group
- aws_ssm_resource_data_sync
- aws_storagegateway_cache
- aws_storagegateway_cached_iscsi_volume
- aws_storagegateway_gateway
- aws_storagegateway_nfs_file_share
- aws_storagegateway_smb_file_share
- aws_storagegateway_upload_buffer
- aws_storagegateway_working_storage
- aws_subnet
- aws_swf_domain
- aws_transfer_server
- aws_transfer_user
- aws_vpc
- aws_vpc_dhcp_options
- aws_vpc_dhcp_options_association
- aws_vpc_endpoint
- aws_vpc_endpoint_connection_notification
- aws_vpc_endpoint_route_table_association
- aws_vpc_endpoint_service
- aws_vpc_endpoint_service_allowed_principal
- aws_vpc_endpoint_subnet_association
- aws_vpc_ipv4_cidr_block_association
- aws_vpc_peering_connection
- aws_vpc_peering_connection_accepter
- aws_vpc_peering_connection_options
- aws_vpn_connection
- aws_vpn_connection_route
- aws_vpn_gateway
- aws_vpn_gateway_attachment
- aws_vpn_gateway_route_propagation
- aws_waf_byte_match_set
- aws_waf_geo_match_set
- aws_waf_ipset
- aws_waf_rate_based_rule
- aws_waf_regex_match_set
- aws_waf_regex_pattern_set
- aws_waf_rule
- aws_waf_rule_group
- aws_waf_size_constraint_set
- aws_waf_sql_injection_match_set
- aws_waf_web_acl
- aws_waf_xss_match_set
- aws_wafregional_byte_match_set
- aws_wafregional_geo_match_set
- aws_wafregional_ipset
- aws_wafregional_rate_based_rule
- aws_wafregional_regex_match_set
- aws_wafregional_regex_pattern_set
- aws_wafregional_rule
- aws_wafregional_rule_group
- aws_wafregional_size_constraint_set
- aws_wafregional_sql_injection_match_set
- aws_wafregional_web_acl
- aws_wafregional_xss_match_set
- aws_worklink_fleet
- aws_xray_sampling_rule