From 834d0533c501c1dd2d32300e41553a18f84a84a2 Mon Sep 17 00:00:00 2001 From: Daniel Haim <2808046+danielhaim1@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:05:33 +0200 Subject: [PATCH 1/3] Update SpaceSafetyLabelType.scala The updated code has removed the UkraineCrisisTopic case object from the list of safety label types. Other than that, there are no significant changes to the code structure, organization, or functionality. This update relates to https://github.com/twitter/the-algorithm/issues/1489 --- .../com/twitter/visibility/models/SpaceSafetyLabelType.scala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/visibilitylib/src/main/scala/com/twitter/visibility/models/SpaceSafetyLabelType.scala b/visibilitylib/src/main/scala/com/twitter/visibility/models/SpaceSafetyLabelType.scala index 432650dfd..551da8433 100644 --- a/visibilitylib/src/main/scala/com/twitter/visibility/models/SpaceSafetyLabelType.scala +++ b/visibilitylib/src/main/scala/com/twitter/visibility/models/SpaceSafetyLabelType.scala @@ -36,7 +36,6 @@ object SpaceSafetyLabelType extends SafetyLabelType { s.SpaceSafetyLabelType.HatefulHighRecall -> HatefulHighRecall, s.SpaceSafetyLabelType.ViolenceHighRecall -> ViolenceHighRecall, s.SpaceSafetyLabelType.HighToxicityModelScore -> HighToxicityModelScore, - s.SpaceSafetyLabelType.UkraineCrisisTopic -> UkraineCrisisTopic, s.SpaceSafetyLabelType.DoNotPublicPublish -> DoNotPublicPublish, s.SpaceSafetyLabelType.Reserved16 -> Deprecated, s.SpaceSafetyLabelType.Reserved17 -> Deprecated, @@ -68,9 +67,6 @@ object SpaceSafetyLabelType extends SafetyLabelType { case object HatefulHighRecall extends SpaceSafetyLabelType case object ViolenceHighRecall extends SpaceSafetyLabelType case object HighToxicityModelScore extends SpaceSafetyLabelType - - case object UkraineCrisisTopic extends SpaceSafetyLabelType - case object DoNotPublicPublish extends SpaceSafetyLabelType case object Deprecated extends SpaceSafetyLabelType From eabae11589205e441fac9acddd5fcc950605340d Mon Sep 17 00:00:00 2001 From: Daniel Haim <2808046+danielhaim1@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:14:41 +0200 Subject: [PATCH 2/3] TensorFlow protocol & bash script improvement 1. The update proposes improvements to a Bash script that runs a Rust application with multiple command line arguments. The suggested changes include adding comments, using variables for each argument, using double quotes for variables, using descriptive variable names, and adding a shebang for the Bash shell specifically. An updated script is provided as an example. 2. The protocol buffer file with version information for serialized data used in TensorFlow now defines a VersionDef message with fields for the producer version, minimum consumer version, and a list of disallowed consumer versions. --- .../tensorflow/core/framework/versions.proto | 39 ++++++++++---- navi/navi/scripts/run_onnx.sh | 38 ++++++++++---- navi/navi/scripts/run_tf2.sh | 51 ++++++++++++++++--- 3 files changed, 101 insertions(+), 27 deletions(-) diff --git a/navi/navi/proto/tensorflow/core/framework/versions.proto b/navi/navi/proto/tensorflow/core/framework/versions.proto index 2cca6e37d..da49a7c70 100644 --- a/navi/navi/proto/tensorflow/core/framework/versions.proto +++ b/navi/navi/proto/tensorflow/core/framework/versions.proto @@ -2,10 +2,19 @@ syntax = "proto3"; package tensorflow; +// Enable arenas for more efficient memory management option cc_enable_arenas = true; + +// Set the outer class name for generated Java code option java_outer_classname = "VersionsProtos"; + +// Generate multiple Java files for the proto package option java_multiple_files = true; + +// Set the Java package name for generated code option java_package = "org.tensorflow.framework"; + +// Set the Go package name for generated code option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto"; // Version information for a piece of serialized data @@ -14,20 +23,28 @@ option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framewo // (GraphDef, etc.), but they all have the same common shape // described here. // -// Each consumer has "consumer" and "min_producer" versions (specified -// elsewhere). A consumer is allowed to consume this data if +// Each consumer has a "consumer_version" and a "min_producer_version". A consumer is allowed to consume this data if // -// producer >= min_producer -// consumer >= min_consumer -// consumer not in bad_consumers +// producer_version >= min_producer_version +// consumer_version >= min_consumer_version +// consumer_version not in bad_consumer_versions // message VersionDef { - // The version of the code that produced this data. - int32 producer = 1; +// The version of the code that produced this data. +int32 producer_version = 1; - // Any consumer below this version is not allowed to consume this data. - int32 min_consumer = 2; +// The minimum consumer version required to consume this data. +int32 min_consumer_version = 2; - // Specific consumer versions which are disallowed (e.g. due to bugs). - repeated int32 bad_consumers = 3; +// Specific consumer versions which are disallowed (e.g. due to bugs). +repeated BadConsumerVersion bad_consumer_versions = 3; } + +// Represents a bad consumer version that is not allowed to consume data. +message BadConsumerVersion { +// The version of the bad consumer. +int32 version = 1; + +// A description of the issue with the bad consumer version. +string issue_description = 2; +} \ No newline at end of file diff --git a/navi/navi/scripts/run_onnx.sh b/navi/navi/scripts/run_onnx.sh index ae6ff10b6..beecc6ab7 100644 --- a/navi/navi/scripts/run_onnx.sh +++ b/navi/navi/scripts/run_onnx.sh @@ -1,10 +1,28 @@ -#!/bin/sh -#RUST_LOG=debug LD_LIBRARY_PATH=so/onnx/lib target/release/navi_onnx --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ -RUST_LOG=info LD_LIBRARY_PATH=so/onnx/lib cargo run --bin navi_onnx --features onnx -- \ - --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ - --model-check-interval-secs 30 \ - --model-dir models/int8 \ - --output caligrated_probabilities \ - --input "" \ - --modelsync-cli "echo" \ - --onnx-ep-options use_arena=true +# This script runs the navi_onnx Rust application with command line arguments. + +# Set variables for command line arguments +LOG_LEVEL="info" +LIB_PATH="so/onnx/lib" +PORT="30" +NUM_WORKER_THREADS="8" +INTRA_OP_PARALLELISM="8" +INTER_OP_PARALLELISM="8" +MODEL_CHECK_INTERVAL_SECS="30" +MODEL_DIR="models/int8" +OUTPUT="calibrated_probabilities" +INPUT="" +MODEL_SYNC_CLI="echo" +ONNX_EP_OPTIONS="use_arena=true" + +# Run the navi_onnx application +RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$LIB_PATH" cargo run --bin navi_onnx --features onnx -- \ + --port "$PORT" \ + --num-worker-threads "$NUM_WORKER_THREADS" \ + --intra-op-parallelism "$INTRA_OP_PARALLELISM" \ + --inter-op-parallelism "$INTER_OP_PARALLELISM" \ + --model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \ + --model-dir "$MODEL_DIR" \ + --output "$OUTPUT" \ + --input "$INPUT" \ + --modelsync-cli "$MODEL_SYNC_CLI" \ + --onnx-ep-options "$ONNX_EP_OPTIONS" diff --git a/navi/navi/scripts/run_tf2.sh b/navi/navi/scripts/run_tf2.sh index 099be4b0d..de2cb7a6e 100644 --- a/navi/navi/scripts/run_tf2.sh +++ b/navi/navi/scripts/run_tf2.sh @@ -1,6 +1,45 @@ -#!/bin/sh -RUST_LOG=info LD_LIBRARY_PATH=so/tf2 cargo run --bin navi --features tf -- --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ - --model-check-interval-secs 30 \ - --model-dir models/click/ \ - --input "" \ - --output output_0 +#!/bin/bash + +# Run the navi application with the following command line arguments + +# Set the log level to info +LOG_LEVEL="info" + +# Set the path to the TensorFlow shared library +TF_SO_PATH="so/tf2" + +# Set the port number to listen on +PORT="30" + +# Set the number of worker threads +NUM_WORKER_THREADS="8" + +# Set the number of intra-op parallelism threads +INTRA_OP_PARALLELISM="8" + +# Set the number of inter-op parallelism threads +INTER_OP_PARALLELISM="8" + +# Set the model check interval in seconds +MODEL_CHECK_INTERVAL_SECS="30" + +# Set the path to the model directory +MODEL_DIR="models/click/" + +# Set the input value +INPUT="" + +# Set the output value +OUTPUT="output_0" + +# Run the navi application +RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$TF_SO_PATH" \ + cargo run --bin navi --features tf -- \ + --port "$PORT" \ + --num-worker-threads "$NUM_WORKER_THREADS" \ + --intra-op-parallelism "$INTRA_OP_PARALLELISM" \ + --inter-op-parallelism "$INTER_OP_PARALLELISM" \ + --model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \ + --model-dir "$MODEL_DIR" \ + --input "$INPUT" \ + --output "$OUTPUT" From 3886a48a3c7932fad6e67396add2196115307fca Mon Sep 17 00:00:00 2001 From: Daniel Haim <2808046+danielhaim1@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:16:11 +0200 Subject: [PATCH 3/3] Revert "TensorFlow protocol & bash script improvement" This reverts commit eabae11589205e441fac9acddd5fcc950605340d. --- .../tensorflow/core/framework/versions.proto | 39 ++++---------- navi/navi/scripts/run_onnx.sh | 38 ++++---------- navi/navi/scripts/run_tf2.sh | 51 +++---------------- 3 files changed, 27 insertions(+), 101 deletions(-) diff --git a/navi/navi/proto/tensorflow/core/framework/versions.proto b/navi/navi/proto/tensorflow/core/framework/versions.proto index da49a7c70..2cca6e37d 100644 --- a/navi/navi/proto/tensorflow/core/framework/versions.proto +++ b/navi/navi/proto/tensorflow/core/framework/versions.proto @@ -2,19 +2,10 @@ syntax = "proto3"; package tensorflow; -// Enable arenas for more efficient memory management option cc_enable_arenas = true; - -// Set the outer class name for generated Java code option java_outer_classname = "VersionsProtos"; - -// Generate multiple Java files for the proto package option java_multiple_files = true; - -// Set the Java package name for generated code option java_package = "org.tensorflow.framework"; - -// Set the Go package name for generated code option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto"; // Version information for a piece of serialized data @@ -23,28 +14,20 @@ option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framewo // (GraphDef, etc.), but they all have the same common shape // described here. // -// Each consumer has a "consumer_version" and a "min_producer_version". A consumer is allowed to consume this data if +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if // -// producer_version >= min_producer_version -// consumer_version >= min_consumer_version -// consumer_version not in bad_consumer_versions +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers // message VersionDef { -// The version of the code that produced this data. -int32 producer_version = 1; + // The version of the code that produced this data. + int32 producer = 1; -// The minimum consumer version required to consume this data. -int32 min_consumer_version = 2; + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; -// Specific consumer versions which are disallowed (e.g. due to bugs). -repeated BadConsumerVersion bad_consumer_versions = 3; + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; } - -// Represents a bad consumer version that is not allowed to consume data. -message BadConsumerVersion { -// The version of the bad consumer. -int32 version = 1; - -// A description of the issue with the bad consumer version. -string issue_description = 2; -} \ No newline at end of file diff --git a/navi/navi/scripts/run_onnx.sh b/navi/navi/scripts/run_onnx.sh index beecc6ab7..ae6ff10b6 100644 --- a/navi/navi/scripts/run_onnx.sh +++ b/navi/navi/scripts/run_onnx.sh @@ -1,28 +1,10 @@ -# This script runs the navi_onnx Rust application with command line arguments. - -# Set variables for command line arguments -LOG_LEVEL="info" -LIB_PATH="so/onnx/lib" -PORT="30" -NUM_WORKER_THREADS="8" -INTRA_OP_PARALLELISM="8" -INTER_OP_PARALLELISM="8" -MODEL_CHECK_INTERVAL_SECS="30" -MODEL_DIR="models/int8" -OUTPUT="calibrated_probabilities" -INPUT="" -MODEL_SYNC_CLI="echo" -ONNX_EP_OPTIONS="use_arena=true" - -# Run the navi_onnx application -RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$LIB_PATH" cargo run --bin navi_onnx --features onnx -- \ - --port "$PORT" \ - --num-worker-threads "$NUM_WORKER_THREADS" \ - --intra-op-parallelism "$INTRA_OP_PARALLELISM" \ - --inter-op-parallelism "$INTER_OP_PARALLELISM" \ - --model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \ - --model-dir "$MODEL_DIR" \ - --output "$OUTPUT" \ - --input "$INPUT" \ - --modelsync-cli "$MODEL_SYNC_CLI" \ - --onnx-ep-options "$ONNX_EP_OPTIONS" +#!/bin/sh +#RUST_LOG=debug LD_LIBRARY_PATH=so/onnx/lib target/release/navi_onnx --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ +RUST_LOG=info LD_LIBRARY_PATH=so/onnx/lib cargo run --bin navi_onnx --features onnx -- \ + --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ + --model-check-interval-secs 30 \ + --model-dir models/int8 \ + --output caligrated_probabilities \ + --input "" \ + --modelsync-cli "echo" \ + --onnx-ep-options use_arena=true diff --git a/navi/navi/scripts/run_tf2.sh b/navi/navi/scripts/run_tf2.sh index de2cb7a6e..099be4b0d 100644 --- a/navi/navi/scripts/run_tf2.sh +++ b/navi/navi/scripts/run_tf2.sh @@ -1,45 +1,6 @@ -#!/bin/bash - -# Run the navi application with the following command line arguments - -# Set the log level to info -LOG_LEVEL="info" - -# Set the path to the TensorFlow shared library -TF_SO_PATH="so/tf2" - -# Set the port number to listen on -PORT="30" - -# Set the number of worker threads -NUM_WORKER_THREADS="8" - -# Set the number of intra-op parallelism threads -INTRA_OP_PARALLELISM="8" - -# Set the number of inter-op parallelism threads -INTER_OP_PARALLELISM="8" - -# Set the model check interval in seconds -MODEL_CHECK_INTERVAL_SECS="30" - -# Set the path to the model directory -MODEL_DIR="models/click/" - -# Set the input value -INPUT="" - -# Set the output value -OUTPUT="output_0" - -# Run the navi application -RUST_LOG="$LOG_LEVEL" LD_LIBRARY_PATH="$TF_SO_PATH" \ - cargo run --bin navi --features tf -- \ - --port "$PORT" \ - --num-worker-threads "$NUM_WORKER_THREADS" \ - --intra-op-parallelism "$INTRA_OP_PARALLELISM" \ - --inter-op-parallelism "$INTER_OP_PARALLELISM" \ - --model-check-interval-secs "$MODEL_CHECK_INTERVAL_SECS" \ - --model-dir "$MODEL_DIR" \ - --input "$INPUT" \ - --output "$OUTPUT" +#!/bin/sh +RUST_LOG=info LD_LIBRARY_PATH=so/tf2 cargo run --bin navi --features tf -- --port 30 --num-worker-threads 8 --intra-op-parallelism 8 --inter-op-parallelism 8 \ + --model-check-interval-secs 30 \ + --model-dir models/click/ \ + --input "" \ + --output output_0