SynapseML icon indicating copy to clipboard operation
SynapseML copied to clipboard

Frozen notebook

Open ezerhoun opened this issue 8 years ago • 6 comments

Hi,

I am trying to run a LightGBM quantile regression on a Toy example but the notebook seems to be stuck and cannot finish.

import pandas as pd
import numpy as np

import os
import pyspark.sql.functions as F

from pyspark.sql import SparkSession, DataFrame
from pyspark import SparkContext
from pyspark.sql.types import DoubleType

spark_context = spark.sparkContext

sql_context = SQLContext(spark_context)
import mmlspark


import pandas as pd
import numpy as np

def xcos(x):
    return x * np.cos(x)

def xsin(x):
    return x * np.sin(x)

def ad_dataset(samples=4000):
    ts = 1501630985
    delta_time_seconds = 600

    f1 = np.atleast_2d(np.random.uniform(0, 10.0, size=samples)).T
    f2 = xcos(f1) 
    y = xsin(f1)
    
    dy = 1.5 + 1.0 * np.random.random(y.shape)
    noise = np.random.normal(0, dy)
    y += noise

    dates = np.linspace(ts, ts + (samples-1) * delta_time_seconds, num=samples).reshape(-1, 1)

    concatenate_array = np.concatenate((dates, f1, f2, y), axis=1)
    concatenate_array = concatenate_array.astype(np.float32)

    df_pd = pd.DataFrame(concatenate_array, columns=["timestamp", "f1", "f2", "y"])

    return df_pd

df = sql_context.createDataFrame(ad_dataset())

features = ["f1", "f2"]
from mmlspark import FastVectorAssembler, SelectColumns
from pyspark.ml import Transformer, Estimator, Pipeline
from pyspark.ml.feature import VectorAssembler

outputFeaturesName = "features"
assembler = FastVectorAssembler(inputCols = features, outputCol=outputFeaturesName)
assembledData = assembler.transform(df)

model = mmlspark.LightGBMRegressor(application='quantile',
                                   alpha = 0.9,
                                   featuresCol=outputFeaturesName, 
                                   labelCol="y", 
                                   learningRate=0.1, 
                                   numIterations=10, 
                                   numLeaves=31, 
                                   predictionCol='prediction').fit(assembledData)

I already contacted @imatiach-msft, this issue is just for tracking purpose.

ezerhoun avatar Jul 10 '18 07:07 ezerhoun

@imatiach-msft I am hitting this as well, and can reproduce with the above notebook.

After a bit of debugging, I have observed:

  • This only happens for quantile application. Other regression losses work fine.
  • The call hanging is Networking::GlobalSum in the serial tree learner when doing RenewTreeOutput: https://github.com/Microsoft/LightGBM/blob/master/src/treelearner/serial_tree_learner.cpp#L800
  • The "small" optimization path is taken: (I have ~~8 executors~~ 2 executors with 4 cores each, and Spark generated 8 tasks, input_size less than 100) https://github.com/Microsoft/LightGBM/blob/master/src/network/network.cpp#L71
  • Recursive doubling is used:
    • The first iterations of the loop work fine, up to the point where we get to send_need_len = recv_need_len = 224, where it starts to hang on SendRecv
    • There, the call to Recv is the one hanging: https://github.com/Microsoft/LightGBM/blob/master/src/network/linkers.h#L247

@imatiach-msft @mhamilton723 any ideas on what could be going on? Does this information help?

peay avatar Jul 18 '18 08:07 peay

@peay @ezerhoun I've created a PR to fix this issue here: https://github.com/Microsoft/LightGBM/pull/1593 I will update LightGBM to latest version in MMLSpark as soon as the other PR goes through code review and is merged

imatiach-msft avatar Aug 17 '18 00:08 imatiach-msft

Thanks @imatiach-msft!

peay avatar Aug 20 '18 13:08 peay

@peay getting a different error on an assert inside lightgbm in the distributed case but only when running on a cluster, the notebook runs for me locally, I created an issue here to ask whether the check in the code is needed: https://github.com/Microsoft/LightGBM/issues/1604

imatiach-msft avatar Aug 23 '18 16:08 imatiach-msft

@peay @ezerhoun there was another fix checked in here: https://github.com/Microsoft/LightGBM/pull/1605 will upload another version of lightgbm to maven central

imatiach-msft avatar Aug 24 '18 05:08 imatiach-msft

PR has been merged, closing issue - will be in 0.14

imatiach-msft avatar Aug 27 '18 15:08 imatiach-msft